• 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

Problem accessing jsp Page

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access a jsp in a directory which is under the my web-app folder

My web-app folder is 'MyApp'.Under that i have made a folder named 'Dir'.
In 'Dir' i have a jsp page named 'First.jsp'.

When i forward the response to the jsp page throught the RequestDispatcher.

RequestDispatcher rd = request.getRequestDispatcher("/Dir/First.jsp");
rd.forward(request,response);

The url shows after this servlet forwards to the jsp is
http://localhost:8080/MyApp/Dir/servlet.do

The servlet.do is the serlet name in which the request dispatcher code is in,but i get a error page with 500 error code.

Please help me.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A code 500 error will occur when there is a problem with processing the page. It means that the page could be found otherwise you would have a 400 status code.
 
Varun Nayudu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What should i do ?
 
Remko Strating
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the error you get?

Maybe the following link could be of help or otherwise show the fault you have.

Problem with requestdispatcher
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post your web.xml
 
Varun Nayudu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
web-app_2_4.xsd" version="2.4">


<servlet>
<servlet-name>serFor</servlet-name>
<servlet-class>com.examples.web.servletFor</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>serFor</servlet-name>
<url-pattern>/Dir/servlet.do</url-pattern>
</servlet-mapping>
</web-app>
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Varun Nayudu:


<servlet-mapping>
<servlet-name>serFor</servlet-name>
<url-pattern>/Dir/servlet.do</url-pattern>
</servlet-mapping>



well, so you keep your jsps and java files under the same directory called Dir!... right? which is so ugly
 
Varun Nayudu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no there are not in the same directory .....servlet files are in the 'classes/com/examples/web' directory and the jsp is in the Dir directory under the context root (accessible directly to the client if requested)
 
Remko Strating
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still don't see your error. What error is displayed?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Varun Nayudu:
servlet files are in the 'classes/com/examples/web' directory and the jsp is in the Dir directory under the context root (accessible directly to the client if requested)



Hello, please see above my my post(url-paatern)....also you need to change your web application structure.
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@seetharaman

Hello, please see above my my post(url-paatern)....also you need to change your web application structure.



Could you please be a bit ore descriptive about the problem you see?

@Varun
Could you please post the exception stack trace that you get?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Varun Nayudu,

sorry!!! now i got your web application structure... not a problem.

and what error you get? please post the error message
 
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

Originally posted by seetharaman venkatasamy:
and what error you get? please post the error message


The error is 500, as mentioned in the original post.

As already pointed above the error is in the page processing.
Can you access the JSP directly ?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amit Ghorpade:

As already pointed above the error is in the page processing.
Can you access the JSP directly ?



i can not get you. can you please explain it bit more ?
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are getting an Error 500, then the server has encountered an "internal" error.

The easiest way to identify the cause is to find the server log file, and look at what exception was thrown!

Assuming you are using TomCat on a local machine then by default the exception will be written to localhost.yyyy-mm-dd.log in your logs sub-directory. Where yyyy-mm-dd is the current date, and the logs sub-directory is usually under the parent tomcat install directory.

For neatness it is sometimes best to stop tomcat, delete ALL the log files, start tomcat then open the URL that is causing the error.

If you need any help diagnosing the error then post the exception details from the log file.

Rufus.
 
Remko Strating
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry. I understood that the error is 500, but I mean what is the exception log, but you already asked that and explained how to find it.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i do not know this would help you or not. Try starting the tomcat using the batch files in the bin dir, this way there will be a command window displaying all the details and logs going on in the tomcat. And you can use the system.out.println statement to check/hint where you are going wrong. And for the tomcat to work i.e. to start properly by using the batch file you must first set all the environment variables set correctly.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic