| Author |
Problem with Jsp Init parameter
|
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
Hi Guys,
I am trying to implement JSP init parameters but i am getting the HTTP 404 error . Please help me out.
My DD(web.xml) has the following definition
My JSP is as follows:
My JSP is in a directory called jsp in my eclipse project. So, should i include the jsp in the <jsp-page> tag and specify the <jsp-page> value as /jsp/JspInitParamaters.jsp?
Also, my eclipse console is not printing out any messages.
When I access this JSP via the URL given in the <url-pattern> tag, i get an HTTP 404 error and when I access the JSP directly i am getting the parameter value as null. I am using Apache tomcat 6.0.29.
Please help.
|
Regards,
Deepak
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
Hi!
Your code works fine on my server.
Did you access an URL that looks like?
http://localhost:8080/WebApplicationRoot/JspInitParams.jsp
note: your context-root should be in the WebApplicationRoot
When I access this JSP via the URL given in the <url-pattern> tag, i get an HTTP 404 error
This just means that the page cannot be found, most probably caused by a wrong directory structure. Try to build a .war file by hand. You can use the following instructions: HowToCreateWebApplicationWithoutAnIDE
when I access the JSP directly i am getting the parameter value as null.
That is correct in order to get to the init parameters you should use the url-pattern in the servlet-mapping element.
Regards,
Frits
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
When I run the same code with apache tomcat 7 i get the following exception. I am clueless.
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
3 questions:
- What is the URL you are accessing?
- How does the directory structure of your web-app look like?
- Did you try to follow the instructions I gave you?
Regards,
Frits
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
Hey Frits, to answer your questions,
1) I am accessing http://localhost:8080/Servlets/JspInitParams.jsp as JspInitParams.jsp is what i have specified as the URL pattern in the servlet mapping.
2) I am using eclipse so, there should not be any issues with the directory structure. FYI i am using a dynamic web project.
3) Yes i tried doing it your way but still got the above exception with tomcat 7.0.12
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
can you check what is deployed on the server:
dirOfYourUser\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 (or tmp1 or tmp2.....)
Is there a directory called Servlets?
can you see the jsp-file there?
Regards,
Frits
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
Yes Frits,
The file JspInitParameters.jsp is there in the Directory workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\Servlets\jsp.
What next?
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
The file JspInitParameters.jsp is there in the Directory workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\Servlets\jsp.
Is it it maybe JspInitParameters.jsp in your project and JspInitParamaters.jsp in your web.xml?
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
Hey Frits,
That was really a very silly spelling mistake. Thanks for pointing it out. It's alright now.
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1039
|
|
That was really a very silly spelling mistake.
I also do that all the time....
Anyway we found it, and it was good for you to see how you can narrow it down by excluding other mistakes (like dir-structure)
Regards,
Frits
|
 |
 |
|
|
subject: Problem with Jsp Init parameter
|
|
|