wood burning stoves 2.0*
The moose likes Servlets and the fly likes Servlet Context Path Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Context Path Issue" Watch "Servlet Context Path Issue" New topic
Author

Servlet Context Path Issue

udhayan kumar
Greenhorn

Joined: Jan 28, 2010
Posts: 16
Hi,


I am developing a web application which has servlets and JSPs.

Here is my folder structure:

Web-Content -> Jsp -> JSP pages
src -> com->servlets-> Java servlet files

Login.jsp which is under Jsp folder will be the welcome file for this application.

so the URL wud I be accessing for login is http://localhost:8080/myapplication

I am calling the "LoginVerifier" servlet upon entering the username and password in login page as below.

<form action="login" method="post">
..
</form>

In logout, I am redirecting to http://localhost:8080/myapplication/jsp/login.jsp.

So here when I click on login button I am getting 404 error since the container expecting myapplication/jsp/login URL pattern which is not there in web.xml as it is defined in web.xml as below:

<servlet-mapping>
<servlet-name>loginservlet</servlet-name>
<url-pattern>login</url-pattern>
</servlet-mapping>

Please help me how it could be resolved.

Your help is much appreciated.
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Hi,

set your welcome file as /jsp/login.jsp

set up your url pattern as /jsp/<servlet> for all the servlets.

Hope this helps.

Thanks


The important thing is not to stop questioning.Curiosity has its own reason for existing.
udhayan kumar
Greenhorn

Joined: Jan 28, 2010
Posts: 16
Vijay Tidake wrote:Hi,

set your welcome file as /jsp/login.jsp

set up your url pattern as /jsp/<servlet> for all the servlets.

Hope this helps.

Thanks


Thanks Vijay. It is working as expected.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Context Path Issue
 
Similar Threads
Servlet cannot access bean/Servlet Not found
trying to run hello world script but it is not
welcome page not comming
http status 404 The requested resource is not available.
jsp, servlet-mapping, forward request problem