File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes URL Rewriting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "URL Rewriting" Watch "URL Rewriting" New topic
Author

URL Rewriting

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
I want to test how URL Rewrite is working? How we can do this? I disabled the cookies in IE, but i don't find the jsessionid in the url... any sample examples...on how to do this?

I tried the below example:


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
It can't do the URL encoding the first time it is accessed, because it doesn't yet know that the browser doesn't accept cookies. But on the second access it should add the session ID in there.

But note that your code doesn't open a session, so there's no point in adding a session ID for a non-existing session.


Ping & DNS - my free Android networking tools app
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9381
    
    2

Where in your code are you asking the container for a session?? Add the line HttpSession session = request.getSession() and then you will find the JSessionID in your url.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
Now I have included the session, but still I don't get the jsessionid in the url.. Also I prompt for the cookies in IE..if I am opening any other site. it's asking whether I allow/block the cookies and some sites don't prompt for it?


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
That's strange. I tried the code with Tomcat and it created a session ID on the very first access. Does your servlet container maybe have settings for enabling/disabling cookies and/or URL rewriting?
Mukesh Mittal
Ranch Hand

Joined: Jan 13, 2006
Posts: 31
I am using WebSphere and on server side I can enable or disable URL writing. May be you can check on your server too.
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
Hi,
I am using Tomcat5.5.20..
To disable cookies in the tomcat server, I have added cookies="false" in the context.xml file in the conf folder, as mentioned by this site (which is searched in google, for diabling the cookies):
web page

And also I have blocked the cookies option in privacy tab for IE..

But still icouldn't see the jsessionid in my url.. why?

In my index.jsp, I am having the link for the above mentioned servlet and the servlet is having the link to the index.jsp page again...
My doubt is whether URL Rewriting has been used correctly by me for the above pgm.

And I have another doubt, when will the URL Rewriting wil come into the picture..only when the cookies are disabled? correct?..but I have gone to sun site to download some docs in JTA, and my browser cookies are allowed, but still the url has jsessionid like below:
https://sdlc3b.sun.com/ECom/EComActionServlet;jsessionid=3D7A3D240421BA1B8CCE9D2F82323DEF
how it is possible?

whether we can come to conclusion that if we have the url that has jsessionid then it is url rewriting and cookies is not working?
[ January 01, 2007: Message edited by: Micheal John ]
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
hi ranchers... any suggestions... for my post
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
It's not so much a question of cookies working or not, but a question of whether the server is configured to use them. Most servlet containers have a setting to always use URL rewriting, regardless of whether cookies would work or not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL Rewriting