You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kief Morris <ki...@bitbull.com> on 2001/02/01 01:22:14 UTC

Re : extracting jsp file name

Shahed Ali typed the following on 04:41 PM 1/31/2001 -0600
>I have a MVC framework in which  all jsp pages post
>data to a controller servlet.
>
>In this servlet, I need to findout which jsp page invoked it.
>
>Currently I am passing a hidden variable with value="/callingpage.jsp"
...
>I want to replace this with some jsp token in each page so that i dont have
>to
>hardcode the jsp page name in every page.
...
>The only way I could think of is getting the generated class name in jsp and
>UnMangling it.

This seems like the very very hard way to do it. Use request.getServletPath()
in the JSP page and stash it in the session.

JSP page:

<% 
    session.setAttribute("domain.mine.myapp.jsp_page", request.getServletPath());
%>

Servlet:
    String jsp_page = request.getSession().getAttribute("domain.mine.myapp.jsp_page");
    if (jsp_page == null) {
        // uh, oh
    }

http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpServletRequest.html#getServletPath()

Kief