EJB design: Attaching Long Object to "request" or "session" object.

  1. 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?
  2. why use a String?

    request.setAttribute("longObj",new Long(cid));
  3. This is not 100%. In your scenario forwarded request must be still the same object. Then you can apply setAttribute. Otherwise setParameter is enough.
  4. 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