Solved

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

Posted on 2004-08-12
9
220 Views
Last Modified: 2010-04-01
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
Comment
Question by:shenlong_wc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11781500
Stick it in the session:

  session.setAttribute( "myobject", list ) ;
0
 

Author Comment

by:shenlong_wc
ID: 11781528
that's gonna be a gross misuse of sessions ?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11781544
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!

 

Author Comment

by:shenlong_wc
ID: 11781593
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
 
LVL 35

Expert Comment

by:TimYates
ID: 11781604
if your jsp calls a servlet, passing it the request object you can put stuff in the request object
0
 

Author Comment

by:shenlong_wc
ID: 11781656
oh, could you show a few lines of codes to demo it ? or point me to an website that teaches it?
0
 
LVL 35

Accepted Solution

by:
TimYates earned 20 total points
ID: 11781668
0
 

Author Comment

by:shenlong_wc
ID: 11781691
thanks !
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11781714
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
nested if has else if 13 100
Prevent Firefox page from going to the background when clicking a spreadsheet link 17 71
maven set up 2 206
Java Script nested call 3 90
Changing a few Outlook Options can help keep you organized!
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question