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

doubts in jsp mapping in DD

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all
I have some doubts .Please anybody try to clear them.

Question 1. Is it compulsory to have a '/' in <jsp-file> element? for example: <jsp-file>/pradeep.jsp <jsp-file>
if i dont use '/' then it is giving error.But we don't use in <servlet-class> element like <servlet-class>myservlet<servlet-class>.

Question 2 When i use below code in web.xml file and call jsp page by: http://localhost:8080/jspfolder/thirdjsp.jsp
It works fine .But when i use http://localhost:8080/jspfolder/third then it is not working .Please tell me why?

<servlet>
<servlet-name>pradeep</servlet-name>
<jsp-file>/thirdjsp.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>pradeep</servlet-name>
<url-pattern>/third</url-pattern>
</servlet-mapping>



Question 3.I have not used <servlet-mapping> in deployment discriptor file for a jsp page but used <servlet> elememnt .I found that it works fine.Does it mean that <servlet-mapping> is not necessary for jsp pages?

[ April 24, 2008: Message edited by: pradeep singh ]
[ April 24, 2008: Message edited by: pradeep singh ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 1: jsp-file must begin with /. The / is not necessary for servlet class paths because, well, the container finds them in the CLASSPATH.

Question 2: Assuming jspfolder is the name of your application, I'm not sure why it wouldn't be working. What does "not working" look like? Does it give a 404 error?

Question 3: You don't have to map JSPs. You might want to if you'd rather expose the JSPs directly but with a different URL. That's about it. I suspect this isn't done often in practice.
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sir
Marc Peabody

For 2 question ,jspfolder is name of my application.Yes it gives 404 error
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any update on above.
 
Jose Luis Huertas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tested the code, but I cannot see why the mapping shouldn't work...

If fact, if you use a <jsp-file> in the <servlet> element but you don't write a <servlet-mapping>, then you won't be able to access any initialization parameter specified in the <servlet>.

See this thread: http://www.coderanch.com/t/177043/java-Web-Component-SCWCD/certification/Cant-read-config-params-JSP

and the HFSJ errata (page 308):

http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic