tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kief Morris <>
Subject Re : extracting jsp file name
Date Thu, 01 Feb 2001 00:22:14 GMT
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
>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());

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


View raw message