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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL rewriting" Watch "URL rewriting" New topic
Author

URL rewriting

George Liao
Greenhorn

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">
<HTML>
<HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="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">
<TITLE>Count.jsp</TITLE>
</HEAD>
<BODY>
<%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");
count[0]++;
//putting the count back into session
out.println("<h2>URL ReWriting</h2>");
out.println("Your Session Id is <b>" + session.getId() + "</b><br>");
out.println(
"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>");
out.println("</form>");
out.flush();%>
</BODY>
</HTML>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL rewriting