Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Appletee, Servletee kind of newbie question! (http://www.velocityreviews.com/forums/t125937-appletee-servletee-kind-of-newbie-question.html)

Andrew Tucker 08-23-2003 06:16 AM

Appletee, Servletee kind of newbie question!
 
Hi everyone,

I am having real problems working out whats going on w/ my applet. I want to
be able to send an object from an applet to a servlet, here is the code for
the listener method causing the trouble:

private void addClientListener(java.awt.event.MouseEvent evt) {

System.out.println("Got this far, addClientListener.");
try {
URL fileURL = new URL(getDocumentBase(),
"servlet/MaintSchedServ");
URLConnection conn = fileURL.openConnection();

conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);

conn.setRequestProperty("addClient", "true");

ObjectOutputStream out = new ObjectOutputStream(new
BufferedOutputStream(

conn.getOutputStream()));

out.writeObject(textField1.getText());
out.close();

} catch( Exception exc ) {
exc.printStackTrace();
}
}
I apologise if my usage of setRequestProperty is incorrect, i need to pass
several different objects to servlet and thought that by using this method
of URLConnection, i could evaluate this at servlet and handle each case
seperately. If there is a better way i would love to know how!

Here is the java console output, it is saying that i need to set doOutput =
true, well i am aren't I?

Thankyou in advance for any direction you can give me!!

Andrew.

Java(TM) Plug-in: Version 1.4.1_02
Using JRE version 1.4.1_02 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Andrew Tucker
/*
options
*/
Stopping applet ...
Unregistered modality listener
Joining applet thread ...
Destroying applet ...
Disposing applet ...
Joined applet thread ...
Quiting applet ...
Finding information ...
Releasing classloader: sun.plugin.ClassLoaderInfo@4865ce, refcount=0
Caching classloader: sun.plugin.ClassLoaderInfo@4865ce
Current classloader cache size: 1
Done ...
Registered modality listener
Referencing classloader: sun.plugin.ClassLoaderInfo@4865ce, refcount=1
Loading applet ...
Initializing applet ...
Starting applet ...
Got this far, addClientListener.
java.net.ProtocolException: cannot write to a URLConnection if
doOutput=false - call setDoOutput(true)
at sun.net.http://www.protocol.http.HttpURLConn...Stream(Unknown
Source)
at AWTMaintSchedGUI.addClientListener(AWTMaintSchedGU I.java:114)
at AWTMaintSchedGUI.access$000(AWTMaintSchedGUI.java: 17)
at AWTMaintSchedGUI$1.mouseClicked(AWTMaintSchedGUI.j ava:51)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)





All times are GMT. The time now is 06:32 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.