Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem accessing jsp Page

 
Varun Nayudu
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • 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.
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • 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: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What should i do ?
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • 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
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your web.xml
 
Varun Nayudu
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • Mark post as helpful
  • send pies
  • 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: 159
  • Mark post as helpful
  • send pies
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't see your error. What error is displayed?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • 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.
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • Mark post as helpful
  • send pies
  • 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
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • Mark post as helpful
  • send pies
  • 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 ?
 
Rufus Addis
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • 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
  • Mark post as helpful
  • send pies
  • 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.
 
prabhu mannu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic