• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Context Path Issue

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 148
Hibernate Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic