Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

encodeURL not working :-(

 
Pat Wallwork
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using encodeURL and encodeRedirectURL on all links on my app. If I enable cookies on my browser nothing is appended to my URL's and I can navigate throughtout my site no problem.
Using Netscape 6.2, if I disable cookies the sessionID is appended to the URL but I get this following error:
You don't have permission to access /processLogin.jsp;jsessionid=dhn1f9rz91 on this server.
I have tried using both relative and absolute URL's, and still get this. Is this likely a problem with the server? (It's Apache and Tomcat 3.2) This is very frustrating as I want to allow users that may have cookies disables to still be able to navigate the site.
Any help, tips, suggestions is really welcome!
Pat
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You don't have permission to access /processLogin.jsp;jsessionid=dhn1f9rz91 on this server

Seems to me that your application is returning an error
by validating the session and since it may think its
expired. Try redirecting the users to the Login page
with a null sessionId.
My $0.02....
- satya
 
Pat Wallwork
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate your reply satya, but I'm not sure if that helps since it works exactly the way it's supposed to when cookies are enabled on a browser. The only time I get this error is when cookies are disabled and the sessionID is appended to the URL. I don't know anything about servers so I'm wondering if this is possibly a problem in the server enviroment, and not something I have done wrong programmatically.
Developing the site using Tomcat as a standalone on my own computer everything worked fine...including navigating the site with cookies disabled. The sessionID was appended to the URL and I never encountered any errors. This only began when I uploaded the site to the live server.
If anyone else has ever had this happen, or has any suggestions I would really appreciate it. This has me terribly stumped :-(
Pat
 
Pat Wallwork
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's all ok now. Apparently it was a configuration problem with Apache. The sysAdmin fixed it but wasn't clear on what exactly was happening.
Pat
 
Adam Hardy
Ranch Hand
Posts: 567
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a similar problem but with a slight variation.
When I disable cookies, the session ID is appended to the URL wherever I use response.encodeURL()
So far so good, but what do I do when I want to append my own parameters to the URL?
If I do it first, for instance:
<A href="<%=response.encodeURL("article.jsp?article_id=" + intID)%>"
I end up with this HTML:
<A href="article.jsp?article_id=5?jsessionid=1241234"

AND if after:
<A href=<%=(response.encodeURL("article.jsp") + "?article_id=" + intID) %>
I get a similar error. If I code it without the "?" then of course it doesn't work when a user has cookies ENabled.
So what do I have to do? Write a function to check the result of encodeURL to find out if I use a "?" or a "+" ?
thanks
Adam
 
Pat Wallwork
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adam,
I have a couple of pages that do that as well and they work fine. I went back and had a look and noticed that I put the URL and the parameters together in a string first, then I used encodeURL like this:
String originalURL = "<a href=\"./members.jsp?page=" + i + "\">";
String encodedURL = response.encodeURL(originalURL);
Any of my links that have parameters are done like this. Try it this way and see if that fixes the problem.
Pat
 
Adam Hardy
Ranch Hand
Posts: 567
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you tested that with cookies disabled? This is exactly what isn't working for me (with Allaire Jrun - which server are you using?)
Adam
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic