Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problem with Jsp Init parameter

 
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Creator of Enthuware JWS+ V6
Posts: 3339
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run the same code with apache tomcat 7 i get the following exception. I am clueless.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3339
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Creator of Enthuware JWS+ V6
Posts: 3339
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Creator of Enthuware JWS+ V6
Posts: 3339
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Frits,

That was really a very silly spelling mistake. Thanks for pointing it out. It's alright now.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3339
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
It's a tiny ad. At least, that's what she said.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic