• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • 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
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.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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