Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Appletee, Servletee kind of newbie question!

Reply
Thread Tools

Appletee, Servletee kind of newbie question!

 
 
Andrew Tucker
Guest
Posts: n/a
 
      08-23-2003
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)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie: how to create this kind of schema mcha226@gmail.com XML 3 12-13-2005 01:41 AM
kind of newbie question in java applete and sites ali Java 2 05-11-2005 11:15 AM
what kind of client do i need ?? Hernán Castelo Wireless Networking 3 05-11-2005 06:29 AM
Router problems of a different kind =?Utf-8?B?c2hhZG8yODI=?= Wireless Networking 1 01-31-2005 11:39 PM
No shame in being a newbie (what kind of lenses do I need)? Rupert Digital Photography 15 09-04-2003 09:25 AM



Advertisments