I am using JBoss 6.0 .
I have deployed my web application: myApp.ear under the web-context: "/test". So in browser-url if I type "http://localhost:8080/test/", I do get my login page (myLogin.jsp).
Since my WAR exists inside a EAR file, I have specified the context root in the application.xml file using a context-root element inside of the web module - i.e.
<module>
<web>
<web-uri>myWeb.war</web-uri>
<context-root>/test</context-root>
</web>
</module>
My question is how to auto direct user to my web-app from "root context"?
I mean if user types "http://localhost:8080/", I would expect my web-application's login page to load (instead of JBoss's default ROOT.war's index.html page).
I deleted existing index.html from {JBOSS}\server\default\deploy\ROOT.war and created a login.jsp there. Now I can see that "login.jsp" is getting invoked when I type http://localhost:8080/. But I can not redirect user-request to my web-app's login page.
In that login.jsp, I have tried with:
<jsp:forward page="/test" />
, but I get error: "HTTP Status 404 - /test".
If I invoke like <jsp:forward page="/test/myLogin.jsp" />
I still get the same 404 error.
Can any one suggest how to achieve the auto-direct to my web-app from root-context?
The answer from Senthil works nice, but user could see the actual redirect done by the browser (page blinks). The redirect can be done also with rewrite [1, 2] functionality of the JBoss server, which supports HTTP Redirect with 30x codes (no blink).
You can either add the rewrite to your app directly (
web.xml
,jboss-web.xml
) and specify the redirect rules inrewrite.properties
- not shown here.Or you can modify the server configuration on it's own without touching the original application. I find this solution handy because the application is left intact.
Use case: We use this for EJBCA deployment (not our app), it sets it's context root to
/ejbca
. We want to preserve the default deployment process provided by the packagedant
script while in the same time we would like to add a redirect from/
to/ejbca
as some kind of default, for user friendliness. If user wants to change it, it's done simply by modifyingstandalone.xml
without need to redeploy the whole app.Edit
standalone.xml
:You need to keep index.html in default deploy folder and forward request to your web module.
For example keep following line only in index.html