Solved

Question on passing values from Servlet TO JSP

Posted on 2002-03-20
4
226 Views
Last Modified: 2013-11-24
I am currently working on a web project that has employed Model 2, wcich is recommended in the specification.
Servlet receives http request and do some work and return
Jsp pages and blah blah...

Question to seasoned experts is as following.

I use the session as interim "basket" to hold the
process results. In other words, Servlet puts the "result"
as an session property(Attribute), then JSP pages uses it
while rendering the page to be displayed. As a project
gets bigger, I have more tedious tasks to keep all
"resulting objects" in order.
I am wondering what architecture or methods other experts
are using in this situation.

I appreciate all comments and advises.

Have a good one...

JY



0
Comment
Question by:joshuayoo
[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
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
pellep earned 300 total points
ID: 6884200
Well, i'm not sure what you're after here. There is no 'magic' to good design. Especially JSP can and do tend to get rather complex as each 'page' may get built by several JSP pages through includes and such.

I guess the only way to go about it (providing you are aiming for a somewhat homogenues design) is to try and think through and identity what specific information needs to be maintained across sessions and request and then enforce that throughout the development. One 'semi-hack' (and I call it that because it's not really within the servlet spec) i've used with great success is the create a 'holder' class with attributes for all values/objects/information that pertains to your site. Create a single instance of this class as the session/request is first created and store the object i your session/request. This way, you have a 'fixed' method of storing/retreiving your information. At least it saves you the agony of having to maintain a design involving zillions of property names in string format.

Anyways, my two cents...
0
 
LVL 1

Expert Comment

by:skinsella
ID: 6888120
instead of using the session, consider using the request.setAttribute() and request.getAttribute().

If the objects created in the servlet are only needed for the resulting JSP, then put them into the request context, and you don't have to worrya bout cleaning them up subsequently.

sean
0
 

Author Comment

by:joshuayoo
ID: 6888748
Thanks for comments, pellep.

Actually, that is what I am doing right now. I was
wondering if I am doing it right. Your comments assured
me that I am doing ok. I wish I had more comments on this.
Well, I think it is time to wrap up and close it down.
I will appreciate if you have more comments.

JY



skinsella, sorry that my question was obscure. I was
working on session-bound data passing...I did not
clearly mention it. I thank you for your comment.



0
 
LVL 4

Expert Comment

by:pellep
ID: 6888781
I'm glad I could raise your confidence in your design. At the end of the day, you have to be comfortable with your design, or you'll have a hard time implemeting it. Good luck!

/Par
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

734 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