• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URL rewriting

 
Greenhorn
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">
<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>
 
No more fooling around. Read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic