473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

JSP/Java: Cookieless Sessions

Hi,
Wonder if someone can help.

We have a client for whom we have to build a website that cannot use
cookies. The server technology will be Unix, JSP/Java, Apache-Tomcat.
Will be using J2SE, no J2EE at all.

So, we'd like to be able to maintain session-like-information e.g.
contents of shopping basket etc, but we absolutely cannot use cookies.

Anyone know of any articles/URL's of how to deal with this?
URL-encoding might be fine, depends upon the length of the browser
string; other options can be considered, but just no cookies.

So, sample code/URL's/articles would be most welcome if at all
possible.
Thanks,
Michela.
Jul 17 '05 #1
2 7832
Liz

"michela rossi" <mi*************@hotmail.com> wrote in message
news:1e**************************@posting.google.c om...
Hi,
Wonder if someone can help.

We have a client for whom we have to build a website that cannot use
cookies. The server technology will be Unix, JSP/Java, Apache-Tomcat.
Will be using J2SE, no J2EE at all.

So, we'd like to be able to maintain session-like-information e.g.
contents of shopping basket etc, but we absolutely cannot use cookies.

Anyone know of any articles/URL's of how to deal with this?
URL-encoding might be fine, depends upon the length of the browser
string; other options can be considered, but just no cookies.

So, sample code/URL's/articles would be most welcome if at all
possible.
Thanks,
Michela.


I was just reading a book on Java Servelets and they talk about this.
You can put the stuff in a database, or in a file, or use some
server methods to store state in the server (not too sure about
this last part).
Jul 17 '05 #2

"michela rossi" <mi*************@hotmail.com> wrote in message
news:1e**************************@posting.google.c om...
Hi,
Wonder if someone can help.

We have a client for whom we have to build a website that cannot use
cookies. The server technology will be Unix, JSP/Java, Apache-Tomcat.
Will be using J2SE, no J2EE at all.

So, we'd like to be able to maintain session-like-information e.g.
contents of shopping basket etc, but we absolutely cannot use cookies.

Anyone know of any articles/URL's of how to deal with this?
URL-encoding might be fine, depends upon the length of the browser
string; other options can be considered, but just no cookies.

So, sample code/URL's/articles would be most welcome if at all
possible.
Thanks,
Michela.


Hi Michela,

There are really only two options available without using cookies: URL
rewriting and parameter passing.

URL rewriting is probably the best option as it won't require much
additional coding since you can use the inbuilt HttpSession to keep track of
data. I assume you know about the Session Tracking API, but if you don't
there are plenty of tutorials available (do a Google search). Or I can
provide some example code.

The problem with URL rewriting is that _every_ URL needs to be encoded in
order to keep the session state. If you have just one URL in the sequence
that hasn't been rewritten, you'll lose the session.

I don't know what you're using at the presentation layer, but if you're
using JSP with the JSTL tag library, this is relatively simple. You just
have to use the <c:url> tag on all links
e.g. <a href="<c:url value="/somePage.jsp"/>">Link</a>

If you're using just servlets/plain jsp you must use the
response.encodeURL() method
e.g. out.print("<a href=\"");
out.print(response.encodeURL("/somePage.jsp"));
out.print("\">Link</a>");

or

<a href="<%= response.encodeURL("/somePage.jsp");%>">Link</a> for
jsp

You also need to encode any URLs used in a redirect:
response.sendRedirect(response.encodeRedirectURL(" http://host/somePage.jsp")
);

For all of the above, the URLs will only be rewritten if cookies are not
available. I assume the requirement that the site cannot use cookies is
because the browser/device doesn't support cookies. If however it is a
strict rule that you cannot _ever_ use cookies even if the browser supports
them, I'm afraid the above won't help. I don't think it's possible to
enforce URL rewriting if cookies are supported and enabled on the browser.

As for URL length, a string of this length will be appended to the links:
jsessionid=5fc50201479a6bffffffff918ed47335519ac:V HwY

Let us know if none of this is an option, or if it doesn't make sense.

HTH
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: JJ | last post by:
Hi, I really need to use cookieless ASP sessions with ASP 3 (IIS5) Can I find out the session ID from the first page, then post it or send it with the url to the next page, then at the start...
0
by: djluker | last post by:
Does anyone know of a way to implement cookieless sessions in ASP.net by tacking on the session ID to the querystring, rather than setting cookieless="true" in the web.config file? I see that some...
3
by: Scott | last post by:
Hello, we are having problems displaying non-aspx files (images, style sheets) since we have upgraded to the 1.1 framework when using a cookieless session (sessionID in the url). Check out...
2
by: Tom Pester | last post by:
I experimented/researched cookieless sessions and tried it on my website. I expected the switch to cookieless sessions to be transparent but this isn' t the case at all: 1) Forms based...
2
by: Steve Franks | last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting a value in the config.web file. However, what if I wanted to determine at run time whether or not I wanted to use...
10
by: Anthony Williams | last post by:
Hi gang, This one looks like a bug :o( As you may or may not know, setting session management in web.config to use cookieless sessions causes the ASP.NET runtime to munge a session ID into...
0
by: Jerad Rose | last post by:
I have an odd scenario. I am working on a hybrid site that uses various development platforms, namely traditional ASP and Lasso (a Mac scripting language). The site uses its own custom sessions...
2
by: rk325 | last post by:
I have a question about cookies & browser permissions and turning off cookies when creating a web site (cookieless mode in web.config). I have a web site that of course uses Session variables....
0
by: Chris Gill | last post by:
I'm trying to use cookieless sessions in asp.net using the InProc mode (for various reasons it is not desirable for us to use the other modes if it is possible to avoid them). My problem revolves...
0
by: David H. | last post by:
Is there any way to have a user use cookieless sessions at runtime on a case-by-case basis? Or do cookieless sessions have to be turned on globally in the web.config for all users of the web...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.