aspose file tools
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

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL rewriting" Watch "URL rewriting" New topic

URL rewriting

George Liao

Joined: May 20, 2003
Posts: 14
I use the following jsp to test url rewriting. I set my ie browser privacy to block all cookies and open a new browser. After I run this jsp, I get "from cookie" on the page. Why I can't get "from url"? I can't see session id after url. I need help. Thanks.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page
contentType="text/html; charset=ISO-8859-1"
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<%session = request.getSession(true);
if (request.isRequestedSessionIdFromCookie()) {
out.println("from Cookies ");
} else if (request.isRequestedSessionIdFromURL()) {
out.println("from url");
if (session.isNew()) {
session.setAttribute("COUNTER_KEY", new int[] { 0 });
int[] count = (int[]) session.getAttribute("COUNTER_KEY");
//putting the count back into session
out.println("<h2>URL ReWriting</h2>");
out.println("Your Session Id is <b>" + session.getId() + "</b><br>");
"You have hit this page <b>"
+ count[0]
+ " </b>times during this browser session<br>");
String url = request.getRequestURI();
out.println("<form method=post action=\"" + response.encodeURL(url) + "\">");
out.println("<br><input type=submit name=submit value=Hit>");
Have you tried LearnNowOnline?
subject: URL rewriting