• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Context Path Issue

 
udhayan kumar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
Hibernate Java Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
udhayan kumar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic