• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

URL rewriting

Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>");
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic