Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

how to pass objects from a servlet to a jsp without a framework ?

hi all,

i'm trying to seperate my business logic layer (servlets) from my presentation layer (jsp) .
for example, if my servlet has a recordset of student records, how do i pass it to a jsp to be displayed ?
i know it can be done in frameworks like spring, but is it achieveable without a framework ?
0
shenlong_wc
Asked:
shenlong_wc
  • 5
  • 4
1 Solution
 
TimYatesCommented:
Stick it in the session:

  session.setAttribute( "myobject", list ) ;
0
 
shenlong_wcAuthor Commented:
that's gonna be a gross misuse of sessions ?
0
 
TimYatesCommented:
Why?

You can also stick it in the request object (if the servlet and the jsp are called via the same request)

  request.setAttribute( "myobject", list ) ;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
shenlong_wcAuthor Commented:
sorry ... din occur to me i can clear the session variable after i receive it.
i was imagining there would be memory problems.

btw, what did you ment when you say "call via the same request ?"
0
 
TimYatesCommented:
if your jsp calls a servlet, passing it the request object you can put stuff in the request object
0
 
shenlong_wcAuthor Commented:
oh, could you show a few lines of codes to demo it ? or point me to an website that teaches it?
0
 
shenlong_wcAuthor Commented:
thanks !
0
 
TimYatesCommented:
Glad to help :-)

Good luck!

Tim
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now