You don't use encodeURL() with the include directive. The include directive
takes a relative path straight to the appropriate JSP and has the same
effect as, say, "#include <stdio.h>" in C code, i.e. the included file is
added to your source prior to compilation. You couldn't write C code like
the following:
char *include_file = "<stdio.h>";
#include include_file
And you can't do something similar with JSP files either:
<%
String included_page = "header.jsp";
%>
<%@ include file=included_page %>
An even more obviously absurd example might be:
<%
String importedPackage = "java.util.";
%>
<%@ page import=importedPackage + "Properties" %>
<%@ page import=importedPackage + "Vector" %>
Even if the JSP compiler accepted this (it won't), the output would be:
String importedPackage = "java.util.";
import importedPackage + "Properties";
import importedPackage + "Vector";
which is illegal Java. However, that dumb example is conceptually the same
as your
<%@ include file="<%= response.encodeURL("header_status_register.jsp")%>" %>
(please note, I'm not saying that you're dumb, simply that a dumb example
can be used to illustrate a technical point).
The JSP <%@ ... %> directives are handled by a pre-processor, just like C
#include statements and the pre-processor does not evaluate Java (or C)
expressions.
You only use encodeURL() for links and encodeRedirectURL() for redirects.
You may want to get a good book on Servlet and JSP programming. I use the
O'Reilly volumes 'Java Servlet Programming' and 'JavaServer Pages'.
Doubtless there are other good titles but you can never go far wrong with an
O'Reilly, I always say.
----- Original Message -----
From: "Anson Zeall" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
Sent: Wednesday, September 10, 2003 10:17 AM
Subject: RE: The function for response.encodeURL....me still not sure
> Thanks a lot,
>
> But......for example...if I have a jsp file..that includes another jsp
> file in it.....how can I write it with encodeURL? Doesn't seem to work..
>
> E.g.
> <%@ include file="<%= response.encodeURL("header_status_register.jsp")
> %>" %> doesn't work
>
> Anson
>
> -----Original Message-----
> From: Christopher Williams [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 10, 2003 5:55 PM
> To: Tomcat Users List
> Subject: Re: The function for response.encodeURL....me still not sure
>
>
> As I said, the URL-rewriting is done by the container to allow you to
> use HTTP sessions when the user of your site has disabled cookies and it
> does this by appending ";jessionid=blah-blah-blah" to end of your URLs
> prior to the query string ("?blah=stuff&jabber=yakka-yakka..."). This
> is all in the servlet spec. However, you need to give the container the
> opportunity to do so and for this you need to use the encodeURL methods
> of HttpServletResponse.
>
> Think about your JSPs. Currently (presumably) you have links like the
> following:
> <a href="some_link.jsp">Some link</a>
>
> To enable session tracking without cookies, all you need to do is:
> <a href="<%= response.encodeURL("some_link.jsp") %>">Some link</a>
>
> Likewise, whenever the logic of your page indicates that a redirect is
> required, instead of calling:
> response.sendRedirect("some_link.jsp");
> you call
> response.sendRedirect(response.encodeRedirectURL("some_link.jsp"));
>
> Check out the J2EE tutorial for examples:
> http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets11.html#63281
>
> Chris.
>
> ----- Original Message -----
> From: "Anson Zeall" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Wednesday, September 10, 2003 2:56 AM
> Subject: The function for response.encodeURL....me still not sure
>
>
> > Hi guys,
> >
> > I was asking about the login stuff before from previous emails and
>
> > trying to avoid the use of cookies. Someone in the group asked me to
> > try
> and
> > use sessions ...using response.encodeURL and stuff. Can someone
> > explain a bit more what that does, or is there a site that can explain
>
> > to me about that?
> >
> >
> >
> > Thanks,
> >
> > Anson
> >
> >
>
>
> ------------------------------------------------------------------------
> ----
> ----
>
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]