Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / June 2004

Tip: Looking for answers? Try searching our database.

integrating JSP with Servlets

Thread view: 
Amy Johnson - 01 Jun 2004 20:23 GMT
I am trying to understand how to calculate data in a servlet, store it
in a bean, then access that data from a JSP. I found an example in a
book, "Core Servlets and JavaServer Pages" (first edition) that says to
do the following in the originate servlet:

Type1 value1 = computeValueFromRequest(request);
getServletContext().setAttribute("key1", value1);

Then the JSP would access the data by setting up the jsp:useBean as follows:

<jsp:useBean id="key1" class="Type1" scope="application" />

I don't really understand this. I'm assumins computeValueFromRequest()
is a servlet method, but I can't find it anywhere. Does anyone have any
ideas?

Thanks much,

Amy
Malcolm Dew-Jones - 01 Jun 2004 23:57 GMT
: I am trying to understand how to calculate data in a servlet, store it
: in a bean, then access that data from a JSP. I found an example in a
: book, "Core Servlets and JavaServer Pages" (first edition) that says to
: do the following in the originate servlet:

: Type1 value1 = computeValueFromRequest(request);
: getServletContext().setAttribute("key1", value1);

: Then the JSP would access the data by setting up the jsp:useBean as follows:

: <jsp:useBean id="key1" class="Type1" scope="application" />

: I don't really understand this. I'm assumins computeValueFromRequest()
: is a servlet method, but I can't find it anywhere. Does anyone have any
: ideas?

It is just a made up name for the example.

They could have said something like this...

 String value1 = "This is an example value";
 getServletContext().setAttribute("key1", value1);

--

(Paying) telecommute programming projects wanted.  Simply reply to this.
Dirk Michaelsen - 02 Jun 2004 09:42 GMT
Hi Amy,

I am doing it this way (you can also use any other type than String):

In the servlet do this:

String anything = "Hello World";
request.getSession().setArrtibute("aName",anything);

In the JSP do this:

String anything = (String)session.getAttribute("aName");

cu
Dirk

>I am trying to understand how to calculate data in a servlet, store it
>in a bean, then access that data from a JSP. I found an example in a
[quoted text clipped - 15 lines]
>
>Amy


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.