• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Calling JSP from servlet 404 error

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im getting the 404 error when im trying to call a jsp file from this servlet.
Is this even the right way to do it?
Here is my doPost method:


 
Louise Blue
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops!! ill remember that the next time...Thank you!!
 
Ranch Hand
Posts: 439
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Morning Louise,

Can you share your directory structure here ? This issue may be just resolved by correctly referencing your JSP page . Also Keep in mind that all URL paths starting with a backslash "/" means they are relative to context root the and the context will not get pre-pended.

Java docs wrote: The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. This method returns null if the servlet container cannot return a RequestDispatcher.

 
Louise Blue
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is how my structure look like:

MinTest (Project name)
Javaresources
Src
Pakke2
GenerelServlet(the servlet that I use)
Webcontent
editio
bootstrap
index2.jsp
 
Saif Asif
Ranch Hand
Posts: 439
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright . And what URL does it show in the browser when it gives the 404 error. It should be http://localhost:8080/MinTest/editio/bootstrap/index2.jsp in order to work fine. Also have you tried to run your code by removing the backslash '/' from the URL in the request dispatcher parameter ?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Saif Asif wrote: It should be http://localhost:8080/MinTest/editio/bootstrap/index2.jsp in order to work fine.


The source directory structure and deployment directory structure may be different. Its the deployment directory structure that really matters.


Here your path to the JSP starts with "/" meaning you are referring this JSP from the ROOT of your web-app.
Your WEB-INF structure should reflect this.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic