This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to stop server from serving index.jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to stop server from serving index.jsp?" Watch "how to stop server from serving index.jsp?" New topic
Author

how to stop server from serving index.jsp?

poli reddy
Greenhorn

Joined: Nov 21, 2007
Posts: 15
Hi
I have a application where I've index.jsp in jsps folder. If the user types http:[path]/conextpath/jsps, the server is redirecting automatically to index.jsp. But I dont want index.jsp to be redirected to the user. instead i want 404 error page to be shown to user. How can i do it? Here the server is redirecting page to index.jsp if it finds index.jsp in that folder. How can i stop this?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Remove the welcome-file-list element from the web.xml file.

Also see http://www.coderanch.com/t/85744/Tomcat/keep-directory-browsing-off for how to prevent the directory contents from being listed.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Lester Burnham wrote:Remove the welcome-file-list element from the web.xml file.

I'm willing to be that there isn't one. Tomcat (and others) supply a default which includes index.jsp.

I'd be more inclined to include a welcome-file-list entry, that specifies a servlet that issues the 404 (or whatever other behavior that you want the root URL to exhibit).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
poli reddy
Greenhorn

Joined: Nov 21, 2007
Posts: 15
thanks Lester Burnham and Bear Bibeault.

That is really nice solution. I am using weblogic server. Could you also please tell me what is the xml file where i can set directory listing param to false?
 
Don't get me started about those stupid light bulbs.
 
subject: how to stop server from serving index.jsp?
 
Similar Threads
Get requested URL
sending parameters through redirecting
response.sendRedirect();jsp:forward;<c:redirect>
Restrict JSP Page
HTML Frames and JSP!