jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes URL rewriting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL rewriting" Watch "URL rewriting" New topic

URL rewriting

Manish Shinde
Ranch Hand

Joined: Mar 30, 2011
Posts: 39
I have some doubts in URL rewriting.
I have made servlet UrlRewrite.java where I m using encodeURL() and then going to
Page Hi.jsp.
When clicked on link, I got Hi.jsp page and jsession id appended to the url.
Then I clicked on link & went to bye.jsp
But this time I go the output as "session is new" .

Question :
1)Is it necessary to use response.encodeURL() everytime when you are navigating form one page to another using <a href=""></a> tags. ?
2)when I use requestDispatcher from Hi.jsp to Bye.jsp.then i got output "session is not new", WHY ?

NOTE : I have disabled browser cookies.

Thanks in advance.
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1341

1. Yes
2. because session is not chnaged as you move from Hi.jsp to Bye.jsp

By the way , your Hi.jsp code is wrong. correct code is

<%@page contentType="text/html" session="true" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
Manish Shinde
Ranch Hand

Joined: Mar 30, 2011
Posts: 39
Thank You
I agree. Here's the link: http://aspose.com/file-tools
subject: URL rewriting
jQuery in Action, 3rd edition