Hey!

If you are running an HTTPSession, then you can put the ListaNoticias
in the session in one servlet and pull it out in the other servlet or JSP.

You might have code like this in your servlet:

      session.putValue("noticias.lista", lista);

then in your JSP, which is another 'servlet', loosely:

LinkedList theLista = (LinkedList) session.getValue("noticias.lista", lista);

There is much code missing above.  If this does not look familiar
to you, then I suggest some study on HTTPSessions.

Sans adieu,
Danny Rubis



Andrés Wagner wrote:

> >ListaNoticias
> >Is this serializable?
>
> Yes. ListaNoticias is a linkedlist that link all the news
> ("noticias"), and the the news class is also serializable and work
> well.
>
> What I need to know is how can the other servlet know the first
> servlet's linkedList without reading it from de HardDisk.
>
> Thanks Again
>
> >
> >If not, then you may have trouble with instantiating the
> >ListaNoticias object.
> >
> >Plus your code doesn't make sense.  Your if-statement will
> >most likely not be executed, so you will NOT get a setAttribute().
>
>         Ups, here is the rigth source:
>
> package burrano;
> import javax.servlet.*;
> .
> .
> ListaNoticias miLista= leer();
>
> public void init() throws ServletException
> {
>         if (miLista == null)
>         {
>         getServletContext().setAttribute("burrano.EnviaNoticia.ListaNoticias",
> leer())
>         }
> }
> public void service(HttpServletRequest req, HttpServletResponse res)
> throws IOException ,ServletException
>
> {
>         try
>         {
>         ObjectInputStream in = new ObjectInputStream(new
> FileInputStream ("myObject"));
>         ListaNoticias ln = (ListaNoticias)in.readObject();
>         in.close();
>         return ln;
>         }
>         catch (IOException e13) {return new ListaNoticias();}
>         catch (ClassNotFoundException eg){return new ListaNoticias();}
> }
>
> >
> >  > I have two servlet and one is trying to access the other servlet's
> >>  linked list. I read the Servlet Online Tutorial but nothing seem to
> >>  work. I have special problems with the method "instance()" that
> >>  appears in the examples...  can anyone explain me how must I write
> >>  the code in the init method in the rigth way?
> >>
> >  > Thanks all for your patience...
> >>
> >
> >  > --------------------
> >>  package burrano;
> >>
> >>  import javax.servlet.*;
> >>  import javax.servlet.http.*;
> >>  import java.io.*;
> >>
> >>  public class buscador extends HttpServlet
> >>  {
> >>          ListaNoticias n;
> >>          public void init() throws ServletException
> >>          {
> >>          n =
> >>
> 
>>>(ListaNoticias)getServletContext().getAttribute("burrano.EnviaNoticia.ListaNoticias");
> >>          }
> >>  .
> >>  .
> >>  .
> >  > }
> >
>
> --
> __________________________________
> Andrés Wagner Acuña
> Estudiante Ing. Civil Industrial
> Universidad Adolfo Ibañez
>
> ICQ: 39542425
> __________________________________
>
> "Programing today is a race between software engineers striving to
> build bigger and better idiot-proof programs, and the universe trying
> to produce bigger and better idiots...
>                                 ...So far the universe is winning".
>
> -Rich Cook
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to