Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when to use encodeURL()

 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read that encodeURL() method helps in passing the session details back to server (i.e to keep the session based conversion alive) and it could be used when cookies are not available or disabled...
so i trying to find when actual it is used and why??
Could any give an example when it is used???
 
raj malhotra
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

so i trying to find when actual it is used and why??

we use url rewriting or cookies to maintain session across web server and browser because they talk using HTTP protocol which is a stateless protocol.Due to stateless nature of http protocol server never recognizes any client(browser) whether it has contacted him previously.so we need to maintain unique identifier in between them.Thats when session managment comes into picture.

when cookies are not available or disabled...


Normally session id is stored in cookie and browser will send that every time it makes request to server.In case if cookie is disabled.and you are not using url rewriting .It is not possible for the web server to recognize the client whether client is requesting first time or already in conversation. So we use url rewriting to generate the urls in the dynamic pages that means we append jsessionid in the url itself so when client submit the request server will get the session id from the url.

Could any give an example when it is used???


 
Ankit Garg
Sheriff
Posts: 9579
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The example given by Raj is absolutely valid, but generally the c:out tag is used in JSPs to encode any URLs with the JSESSIONID value (i.e. the backup to maintain session if cookies are disabled). Generally the encodeURL method is used in servlets i.e. servlets that generate HTML output as servlets don't have c:out tags, so this is their only options...
 
Tomasz Szymanski
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:but generally the c:out tag is used in JSPs to encode any URLs


All true, except it's the c:url tag. I'm sure that's what you meant ;-)
 
chandan kumar mitwaa
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit,
I would like to clarify on <c: out> or <c:url> . Which one of these is used for url rewriting???
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chandan kumar mitwaa wrote:Ankit,
I would like to clarify on <c: out> or <c:url> . Which one of these is used for url rewriting???

You can trust Tomasz on that one.
 
chandan kumar mitwaa
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's ok Christophe.

Just 10 seconds gap between the two messages. I knew.
 
Ankit Garg
Sheriff
Posts: 9579
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya so I screwed up, this happens when there are background threads running in my mind (and they are a lot in quantity) :-) ...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I didn't notice that you almost posted at the same time.
 
subodh gupta
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Its c:url, cut is used to print out something on the page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic