Re: Using serialization to re-/store state:UnknownServiceException:protocol doesn't support output:

Geeta Ramani <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Organization Central Maine Power Company
Message-ID <[email protected]>
uh, oh.  I don't think this will work after a server reboot. You will, I think,
have to think about storing info in a database, or if the info is not too
complicated, maybe in a flat file on the server ..

Geeta

Carl Woermann wrote:

> Hi Geeta;
> I've looked at it, but I I think I should have been more specific: the
> persistance I was hoping to achive was after server reboot.. so I suppose I
> should try application.setAttribute("myData", myBean); etc?
>
> Thanks CARL.
>
> Hi Carl:
>
> I am not sure, maybe I misunderstand your problem, but aren't you working
> too
> hard? Why don't you use session variables here? As in:
>
> Save your bean data as follows:
> session.setAttribute("myData", myBean);
>
> And then when you want the data later, retrieve it as follows:
> MyBean myBean = (MyBean)session.getAttribute("myData");
>
> In case this will do it for you, you may want to know that sessions have
> bene
> extensively discussed in the archives...:)
> Geeta
>
> Carl Woermann wrote:
>
> > Hi all..
> >
> > I'm using jsp & tomcat4.
> > The application collects user data.
> > I have a bean that contains all relevant data.
> > I am using serializtion to make the data persistant.
> > In order to restore the state of the bean I use:
> >
> > <% URL resourceUrl =
> > application.getResource("/resource/SerializedBean.ser"); %>
> >
> > // returns a valid url: jndi:/localhost/resource/MemberBean.ser
> >
> > <jsp:useBean  id="registrationBean" scope="application"
> > type="Package.class" beanName="Package.SerializedBean" >
> > <%
> >  // the saved version is restored if there is no instance of this bean.
> >  boolean bool = registrationBean.restoreState(registrationBean,
> > resourceUrl);
> >  out.print("restored state: " + bool); //for debugging purposes..
> > %>
> > </jsp:useBean>
> >
> > When saving the state with:
> >
> > registrationBean.saveState(resourceUrl);
> >
> > I get the following exception report:
> >
> > Starting service Tomcat-Netbeans
> > Apache Tomcat/4.0.4
> > restoring state : jndi:/localhost/resource/MemberBean.ser
> > saving state to : jndi:/localhost/resource/MemberBean.ser
> > can do output: true */ SEE METHOD CALL BELOW /*
> > java.net.UnknownServiceException: protocol doesn't support output
> >         at java.net.URLConnection.getOutputStream(URLConnection.java:679)
> >                 etc...
> >
> > the code of the save state method is below:
> >
> > public synchronized void saveState(URL url){
> >         this.url = url;
> >         try {
> >         URLConnection uConn = url.openConnection();
> >         uConn.setDoOutput(true);
> >         if (debug)
> >             { System.out.println("can do output: " +
> uConn.getDoOutput()); }
> >
> >                 OutputStream out = uConn.getOutputStream();
> >             ObjectOutputStream s = new ObjectOutputStream(out);
> >             s.writeObject(this);
> >             s.flush();
> >             s.close();
> >          uConn.setDoOutput(false);
> >         }
> >         catch(FileNotFoundException fnfex){ fnfex.printStackTrace(); }
> >         catch(IOException ioe){ ioe.printStackTrace(); }
> >     }
> >
> > Can anybody shed some light on this problem?
> > What other means are availiable to make beans persistant within a Servlet
> > Container?
> >
> > Any suggestions are greatly appreciated.
> >
> > Thank you
> > CARL WOERMANN
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Everything you'll ever need on one web page
> > from News and Sport to Email and Music Charts
> > http://uk.my.yahoo.com
> >
> >
> ___________________________________________________________________________
> > 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
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> ___________________________________________________________________________
> 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
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> ___________________________________________________________________________
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.