Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet mapping

 
Luk Kopacki
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Inside my web.xml:

<servlet>
<servlet-name>bigServlet</servlet-name>
<jsp-file>big_common/_getdata.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>bigServlet</servlet-name>
<url-pattern>big/servlet/*</url-pattern>
</servlet-mapping>
The problem is when I'm trying to invoke request.getServletPath() inside _getdata.jsp, because it returns path:"/big_common/_getdata.jsp". But when I use <servlet-class>BigServlet</servlet-class> instead of <jsp-file> then the
result of request.getServletPath(), invoked inside BigServlet, is "big/servlet/".Why I can't get path from <servlet-mapping> inside jsp file?
 
Gert Cuppens
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The impression I get from reading your text, is that you're complicating your life. I never mention my JSP's inside the web.xml. In my last web application, I only mentioned one servlet in the web.xml. This servlet decides which JSP it should call, depending on the different parameters which are in the request. So I wonder why you should be able to read the servletpath in your JSP.
Try to let the servlet do all the work and let the JSP do the layout work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic