Reputation: 21
I created index.jsp
page and binded path /index
to it in web.xml
.
It's also displayed when accessing the root of application as welcome page. It has three init parameters.
The problem is I can access then from JSP code by config.getInitParameter()
if the path is full [host:port]/[appName]/index
, the parameters are accessed normally.
If I try to navigate to application root [host:port]/[appName]/
welcome page is displayed but init parameters can't be accessed. config.getInitParameter()
method returns null.
How to configure welcome page properly in web.xml if I want to get servlet init parameters?
Upvotes: 2
Views: 1118
Reputation: 3749
Usually in Java, if you want to use / to access a Java EE context, you would either:
The second method is the most common solution. In this case the request goes Browser -> Reverse Proxy / Load Balancer -> One or more application servers.
This has several advantages.
Upvotes: 2
Reputation: 556
Do you have index.jsp defined as a "welcome-file" in web.xml? It sounds like the container is doing a redirect. Defining index.jsp as a welcome-file should fix that.
Hope that helps.
Upvotes: 2