Solved

Question on passing values from Servlet TO JSP

Posted on 2002-03-20
4
201 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now