You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jason Novotny <JD...@lbl.gov> on 2001/02/01 22:09:09 UTC

simple jsp forwarding

My idea is to create a generic template jsp file that can include other jsps
depending on a request parameter.

So I have  a link like the following:

<a
href="/example/jsp/template.jsp?mainpage=/example/jsp/login.jsp">Login</a><br>

And then my template jsp has the following:

...
<% String mainpage = request.getParameter("mainpage");  %>
<jsp:include page="<%= mainpage %>" flush="true" />
...

    However in practice, it seems to display login.jsp in another browser window
and not even invoke template.jsp from the link.

If there's a JSP guru out there, I really appreciate the wisdom :-)

    Jason


--
Jason Novotny               novotny@george.lbl.gov
Home: (510) 704-9917        Work: (510) 486-8662
NERSC Distributed Computing http://www-didc.lbl.gov




RE: simple jsp forwarding

Posted by Debra Locke <dl...@powervision.com>.
We typically use a jsp template which dynamically creates all display pages
using several jsp pages. However we do not use links to accomplish this.
Instead we have a class file that defines "defaults" for request attributes
(i.e. public static final String ATTR_CONTENT_JSP = "DisplayContent";) that
we have created. Then within the java code for processing a request, we set
the attribute to the appropriate jsp page for the task at hand (i.e.
request.setAttribute(ATTR_CONTENT_JSP,"/example/jsp/login.jsp");). Then
within the template jsp page, we simply retrieve the current value of the
attribute.

This allows us to use the following in our template jsp page:


           <%
              pageContext.getOut().flush();
              String y = (String)request.getAttribute("ATTR_CONTENT_JSP");
              if ((y== null) || (y.length() == 0)) {
                  %>
                  Error: JSP page not specified for template
                  <%
              }
              else {
                  pageContext.include(y);
              }
           %>


Hope this helps.

Regards,
Debbie
-----Original Message-----
From: novotny@lbl.gov [mailto:novotny@lbl.gov]On Behalf Of Jason Novotny
Sent: Thursday, February 01, 2001 4:09 PM
To: tomcat-user@jakarta.apache.org
Subject: simple jsp forwarding



My idea is to create a generic template jsp file that can include other jsps
depending on a request parameter.

So I have  a link like the following:

<a
href="/example/jsp/template.jsp?mainpage=/example/jsp/login.jsp">Login</a><b
r>

And then my template jsp has the following:

...
<% String mainpage = request.getParameter("mainpage");  %>
<jsp:include page="<%= mainpage %>" flush="true" />
...

    However in practice, it seems to display login.jsp in another browser
window
and not even invoke template.jsp from the link.

If there's a JSP guru out there, I really appreciate the wisdom :-)

    Jason


--
Jason Novotny               novotny@george.lbl.gov
Home: (510) 704-9917        Work: (510) 486-8662
NERSC Distributed Computing http://www-didc.lbl.gov




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, email: tomcat-user-help@jakarta.apache.org