>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