Hi:

URL rewriting is another way to support anonymous session tracking.
With URL rewriting every local URL the user might click on is dynamically
modified, or rewritten to include extra information.

The extra information that you want to add could be extra path information,
added parameters or some custom, server-specific URL change. Generally, the
servlet developer prefers to put in a unique session ID.

URL rewriting works for all dynamically created documents which includes
forms.
This is a visible advantage over hidden fields which have form-based
dependency.

Now how to implement it in JSP,
In order to support URL rewriting you should avoid writing a URL straight
to the output stream from the JSP. Instead use the
HttpServletResponse.encodeURL() method.

This method does two things,
1. it determines if the URL needs to be rewritten
2. and if so, it rewrites it, by including the sessionID in the URL.

For the code,
Check if the 1st JSP file has the code which matches this pattern
<a href=<%=response.encodeURL("/foodir/foo.jsp")%> > Some Click here </a>

Additionally, you will redirect wherein you need to write code that matches
this pattern
response.sendRedirect( response.encodeRedirectURL("/foodir/foo.jsp"));

Hope this helps.

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Parag V Thakur
Sent: Thursday, September 28, 2000 11:50 PM
To: [EMAIL PROTECTED]
Subject: what is URL rewriting?


hi!

it might be a stupid question, but what exactly is URL rewriting?
I am trying to do the following:
---------------
String eventName = request.getParameter("eventName");
...
if(eventNotFound) {

    <jsp:forward
page="eventNotFound.jsp?event=<%=URLEncoder.encode(eventName)%>"/>
}
-----------------

is this URL rewriting? also, could anyone tell me why this code is not
running?
the error i get is:

javax.servlet.ServletException
        at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:386)
        at
_0002feventView_0002ejspeventView_jsp_36._jspService(_0002feventView_0002ejs
peventView_jsp_36.java:447)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
        at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
        at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
        at java.lang.Thread.run(Thread.java)

Root cause:
java.lang.IllegalArgumentException
        at javax.servlet.http.HttpUtils.parseName(HttpUtils.java:285)
        at javax.servlet.http.HttpUtils.parseQueryString(HttpUtils.java:154)
        at
org.apache.tomcat.core.RequestDispatcherImpl.addQueryString(RequestDispatche
rImpl.java:326)
        at
org.apache.tomcat.core.RequestDispatcherImpl.forward(RequestDispatcherImpl.j
ava:155)
        at
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:357)
        at
_0002feventView_0002ejspeventView_jsp_36._jspService(_0002feventView_0002ejs
peventView_jsp_36.java:195)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
        at
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
        at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
        at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
        at java.lang.Thread.run(Thread.java)


thanks!
parag.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to