-
Attaching Long Object to "request" or "session" object. (3 messages)
- Posted by: Devarajan Ramakrishnan
- Posted on: May 14 2003 22:29 EDT
I have a scenario whereby I forward the HTTP request from Servlet to a JSP for a HTML display. While doing so, I need to attach a "long" value to the "request" object. My solution was to use Long.valueOf(Long.toString(cid)) and attach the "Long" value. Although this solves my purpose, can anybody suggest a better way of doing this?Threaded Messages (3)
- Attaching Long Object to "request" or "session" object. by Fabrizio Gianneschi on May 16 2003 04:37 EDT
- Attaching Long Object to "request" or "session" object. by Richard Holly on May 22 2003 09:31 EDT
- Attaching Long Object to "request" or "session" object. by Aaron Robinson on May 18 2003 14:22 EDT
-
Attaching Long Object to "request" or "session" object.[ Go to top ]
- Posted by: Fabrizio Gianneschi
- Posted on: May 16 2003 04:37 EDT
- in response to Devarajan Ramakrishnan
why use a String?
request.setAttribute("longObj",new Long(cid)); -
Attaching Long Object to "request" or "session" object.[ Go to top ]
- Posted by: Richard Holly
- Posted on: May 22 2003 09:31 EDT
- in response to Fabrizio Gianneschi
This is not 100%. In your scenario forwarded request must be still the same object. Then you can apply setAttribute. Otherwise setParameter is enough. -
Attaching Long Object to "request" or "session" object.[ Go to top ]
- Posted by: Aaron Robinson
- Posted on: May 18 2003 14:22 EDT
- in response to Devarajan Ramakrishnan
Or if you did want a String representation...
"" + cid
You'll be pleased to hear that JDK 1.5 is introducing something called autoboxing which will stop you having to perform this wrapping stuff