Reputation: 23
I want to develop a application
and deploy
in WebSphere
where the requirement is:
if there are any request like http://appserver1:9080/
- it will reach to a landing jsp page
for example http://appserver1:9080/index.jsp
Is it at all possible to redirect to a page even if I don't mention the resource name?
Upvotes: 0
Views: 2026
Reputation: 4250
If you want to redirect from server's root, this is not about your java code or project configuration, it is about server configuration. Look here for WebSphere configuration.
For JEE projects, on web.xml, you can define as;
<web-app>
....
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
</welcome-file-list>
</web-app>
So
http://localhost:8080/myproject
will load index.jsp
Source for details
Upvotes: 1
Reputation: 90
From what you are describing, the redirection can be pretty much handled by servlets mapping. Read here:
https://docs.oracle.com/cd/E13222_01/wls/docs92/webapp/configureservlet.html
You can be able to intercept URL requests and process:
// Servlet definition on your web.xml
<servlet>
<servlet-name>ServletHandler</servlet-name>
<servlet-class>com.servlets.ServletHandler</servlet-class>
</servlet>
// This maps all requests to the above defined servlet for processing:
<servlet-mapping>
<servlet-name>ServletHandler</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
I hope this helps
Upvotes: 1
Reputation: 36143
You can define welcome files in web.xml
<web-app>
...
<welcome-file-list>
<welcome-file>index.jsp/welcome-file>
</welcome-file-list>
...
</web-app>
But according to the spec index.html, index.htm and index.jsp are welcome files by default. So you probably don't need to configure anything when the file is called index.jsp.
Upvotes: 0