HELP!
I'm trying to send a doGet request to a servlet and have it respond by sending
me a serialized object.
I've managed to POST a serialized object to the servlet.
The object is created from a class in the same directory as the servlet and
sent to the applet class in the root context directory.
The same class that creates the object is also in the root directory for
disasembly.
The request gets to the servlet and the servlet responds, the object is created
okay and it appears to be sent, as no exceptions for the stream are generated.
But the objects contents are all zero or null.
I'm following Jasons book page 322/323 chpt10 to the letter. Though the code
below may contain some other bits n' pieces I've tried in desperation
Also, I thought it may be to do with different JDK versions in use, so I
recompiled them all in 1.3 and it made no difference. But curiously the applet
worked in my IE browser which only supports 1.1 so I'm not sure what's going off
there!
I' ve been at these few lines of code for 12 hours now. grrrrrrrrr
PLEASE HELP.
Thanks in advance,
mike
E.o & P.o are just my debugging info methods
//SERVLET
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
log("(in doGet) Content Type "+req.getContentType());
if("true".equals(req.getParameter("extract"))) {
log("EXTRACTING FROM BAG via new Dealer()");
ObjectOutputStream oos = new ObjectOutputStream(res.getOutputStream());
Dealer deal = new Dealer();
E.o("deal = "+deal); // test obj id
E.o("Bag Quant *** = "+deal.bagQuant); // **OKAY HERE**
E.o("Dealer object created");
try {
oos.writeObject(deal);
}
catch(IOException ex) {E.o("IOException = "+ex);}
E.o("Dealer object written to stream");
oos.flush();
oos.close();
}
//APPLET
public void newExtract() {
P.o("Contacting servlet with extraction request");
ObjectInputStream ois = null;
Object obj = null;
Dealer dealt = null;
try {
URL url = new URL(getCodeBase(),"/bob/servlet/bob?extract=true");
URLConnection urlCon = url.openConnection();
E.o("URL IS "+urlCon.getURL());
//urlCon.setRequestProperty("Content-Type", "extract");
//urlCon.setDoOutput(true);
//urlCon.setDoInput(true);
//urlCon.setDoOutput(true);
urlCon.setUseCaches(false);
//urlCon.setRequestProperty("Content-Type","application/x-java-serialized-object
");
ois = new ObjectInputStream(urlCon.getInputStream());
obj = ois.readObject(); // Dealer object with grid, hand & bagQuant
ois.close();
dealt = (Dealer)obj;
P.o("dealt = "+dealt);
P.o("dealt.bagQuant"+dealt.bagQuant); **zero here**
PS my e-mail reply is set to the same as it is sent out under
___________________________________________________________________________
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