First of all thansk alooooooooooooooooooooot!
well i'm working on a search engine !
my first page query.jsp includes the nuoput an a buton that leads to the
second page result.jsp!
the result contains two beans
<jsp:useBean id="process" scope="session"
class="MyBeanPackage.processesMyBeanClass">
<jsp:setProperty property="*"/>
and
<jsp:useBean id="hit" scope="session" class="MyBeanPackage.hits"/>
then
i use hit=process.getresult();
and display 10 of the results of hit;
then i have a button next for displaying the next 10 and so on
but in that same page i also have an input for another query !
the button leads to that same page with a parameter of the position from
which to stat displaying the result of hit !
when i click on it , it displays the right next results but it takes time by
reinstatiating the process bean , i 'lm sure of it cause when i dsiconnect
from internet, that process bean uses , i have an error thrown by process
bean !
Thanks again


>From: "Duffey, Kevin" <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: passing ogjects from jsp to jsp
>Date: Thu, 21 Jun 2001 10:33:49 -0700
>
>So let me see if I got this right. You have Bean 1 on page 1. You get some
>values from a form on that page and store it in bean 1 (perhaps by
>auto-population of the bean using the <jsp:setProperty property="*"/>?). In
>your servlet (or whatever) you use those values to do a query. The result
>of
>the query is stored in a Vector (or something) in Bean2. You then forward
>(or redirect) to Page 2. In that page, you use the Bean 2 and want to list
>only a subset of the results. You include a NEXT button. Bean 2 "should" be
>session scope for this to work, where as Bean 1 can be request scope since
>you are only submitting the query the user types in one time..and there is
>no need to store what they typed (unless..ofcourse this is a search engine
>or something and you want to preserve what they typed in to show it to them
>again). So on page 2, you have say, 10 of 100 results displayed. Now, they
>hit the next button. Obviously you will need a "postion" indicate in bean 2
>as well, so when they hit NEXT, it increments the position indicator by
>what
>ever factor (10 in this case). So now, your page 2 is displayed again. This
>time it starts from the next sub-set and displays the next say, 10 items.
>So, what I am not sure I understand is why your having any problems. If
>bean
>2 carries the results (lets again assume a Vector of some objects), and
>your
>using Bean 2 as SESSION scope on page 2, there should be no reason why you
>can't list the sub-set items.
>
><jsp:useBean id="Bean2" scope="session" class="MyBeanPackage.MyBeanClass"/>
>
>   <table>
>     <tr>
>       <td>Result</td>
>     </tr>
><%
>   List l = Bean2.getResults();
>   int len = l.size();
>   int start = Bean2.getPosition();
>   for( int cntr = start; cntr < start + 10; cntr++ )
>   {
>     Object o = l.get(cntr);
>%>
>   <tr>
>     <td><%= o.getResultName() %></td>
>   </tr>
><%
>   }
>%>
>
><form name="ResultForm" method="post" action="SomeActionToTake">
>   <input type="image" src="/images/prev.gif" border="0"
>onClick="this.form.action="SomeActionToTake?prev=true">
>   <input type="image" src="/images/next.gif" border="0"
>onClick="this.form.action="SomeActionToTake?next=true">
></form>
>
>
>
>In your servlet you might have something like:
>
>if( request.getParameter("prev") != null )
>{
>   // prev was selected..remove 10 from bean start position, then forward
>to
>that JSP page again.
>   Bean2 b = (Bean2) request.getSession(true).getAttribute("Bean2");
>   b.setPosition( b.getPosition() - 10 );
>}
>else
>{
>   // next was selected..add 10 from bean start position, then forward to
>JSP
>page again.
>   Bean2 b = (Bean2) request.getSession(true).getAttribute("Bean2");
>   b.setPosition( b.getPosition() + 10 );
>}
>
>
>
>Now mind you, I am not doing any checking here. Also, the two sumbit
>buttons
>are images right now, and they use a javascript onclick handler to set the
>action. You can just as easily use two different forms, or use HRefs to
>submit to the server which way to navigate. If the user can enter any data,
>check boxes, etc, you will have to use a form to submit what they select or
>type in, otherwise, href should be fine if you only providing some text
>info
>via the search results, and a next/prev button. Also, in my JSP example, I
>am using Object as the result. Replace this with your object being stored
>in
>the List, and replace List with HashMap or whatever mechanism you are using
>to store the list of items. Generally a ResultSet is a Vector.
>
>Hope this helps..if not, feel free to ask more.
>
>
>-----Original Message-----
>From: kaab kaoutar [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, June 21, 2001 8:02 AM
>To: [EMAIL PROTECTED]
>Subject: Re: passing ogjects from jsp to jsp
>
>
>Thanks a lot!
>But wht i'm doing so far is to get a request tehn instantiate a bean(bean1)
>get the result, store it in another (bean2), then i display some of the
>content of bean2(linked list) and add a next button so as to display the
>rest of the bean2 in another page(the same that is reloaded)! what u said
>is
>ok but what if the user enters another query will the content change of
>bean2?
>By the way i know some of sessions but i used to work with php!
>
>
> >From: Kevin Duffey <[EMAIL PROTECTED]>
> >Reply-To: A mailing list about Java Server Pages specification and
> >reference <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: Re: passing ogjects from jsp to jsp
> >Date: Thu, 21 Jun 2001 07:50:36 -0700
> >
> >Very simple. Store the result set in a bean with session scope. Then, all
> >pages accessed by the same one user during the same one session (most
> >servlet engines default 30 minutes of inactivity for a session before
> >expiring it) can access this list. If your not familiar with "scope", its
> >handy to know. There are basically 3 scopes with beans. Request, Session
> >and
> >Application. Request means the object exist for the duration of the
>request
> >on the server (including forwarding to a JSP page..so you can have a
> >servlet
> >put an object in the request passed in, then forward to a JSP page that
> >also
> >has access to this same object. The engine then discards that object once
> >the response goes back to the client). Session exists the entire time the
> >user is using your site while their session is still kept alive. All
>pages
> >they access can access this one object (or any object stored in the
> >session). Application scope is dangerous but sometimes useful. Its a
>GLOBAL
> >scope that all sessions can use. Therefore its not thread-safe. It is
> >useful
> >for lookup objects, or routines that are used by many pages for many
> >sessions at the same time. But remember, do not put any methods in an
> >object
> >that can be "written" to at the same time without first syncronizing the
> >method(s).
> >
> >So to store something for the next page to access, you do something like:
> >
> >request.getSession(true).setAttribute("AttributeName", object);
> >
> >On the following page, you will have to typecast the object to the right
> >type:
> >
> >MyObject myObject = (MyObject)
> >request.getSession(true).getAttribute("AttributeName");
> >
> >If this hasn't helped, elaborate a bit more and I'll see what I can do.
> >
> >
> > > -----Original Message-----
> > > From: A mailing list about Java Server Pages specification and
>reference
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of kaab kaoutar
> > > Sent: Thursday, June 21, 2001 3:48 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: passing ogjects from jsp to jsp
> > >
> > >
> > > Hi!
> > > I have a jsp files that generates a linked list by the bean that are
> > > instantiated there!
> > > iwant the next page to get that linked list and display some of the
> >liked
> > > list then call itself with an argument so as to display the rest
> > > and so on !
> > > The main problem is how the second page can use the result es
> > > linked list of
> > > the first page
> > > Thanks
> > >
> >_________________________________________________________________________
> > > Get Your Private, Free E-mail from MSN Hotmail at
> >http://www.hotmail.com.
> > >
> > > ==================================================================
> > > =========
> > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > > JSP-INTEREST".
> > > For digest: mailto [EMAIL PROTECTED] with body: "set
> > > JSP-INTEREST DIGEST".
> > > Some relevant FAQs on JSP/Servlets can be found at:
> > >
> > >  http://java.sun.com/products/jsp/faq.html
> > >  http://www.esperanto.org.nz/jsp/jspfaq.html
> > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> >===========================================================================
> >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >JSP-INTEREST".
> >For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> >DIGEST".
> >Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to