| Author |
Grabbing session variables without being in a Web Application
|
Francesco Marchioni
author
Ranch Hand
Joined: Sep 22, 2003
Posts: 175
|
|
Hi all, forgive the strange question, let me explain better. Sometimes in a client application I have to collect information (for log purposes) about a web application. Let's say I have a String like "http://mysite/mypage.jsp?var1=5&var2=1" Now I want to extract the URI information as well as variables from the client side. Let's say I'm not on the serverside staff so I cannot have my servlet pass this information in any way. If I'm in a web context it's easy...just query the request object. But what about if I'm not inside a Servlet ? can I build a HttpRequest object for the sole purpose of working on a URL, and extracting this info ?? or my only chance is to substring() the String ? (which, I admit, I hate it!) Thanks a lot Francesco
|
JBoss AS 5 Development
JBoss Tutorials
|
 |
Jeroen Wenting
Ranch Hand
Joined: Oct 12, 2000
Posts: 5093
|
|
You can't access the HTTP Session clientside as it is maintained purely on the server. Only the session ID is sent to the client, either as part of the URL or as a cookie. So you'll have to examine the HTTP headers and URL String and hope those contain the info you want.
|
42
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
I think you're just asking about parsing that string to read all the variables. You can use StringTokenizer or regular expression Patterns several times: Put that in a nice little parser class and don't lose it. This sounds like something you'll need to to again some day!
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Francesco Marchioni
author
Ranch Hand
Joined: Sep 22, 2003
Posts: 175
|
|
Hi, thanks a lot for your answer. Well I hoped it was possible somehow to "recycle" the parsing logic from Servlet Api...never mind I'll build my own class and do it as suggested. Regards Francesco
|
 |
 |
|
|
subject: Grabbing session variables without being in a Web Application
|
|
|