The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Unable to call servlet from JApplet embedded in IE5 with tomcat.

Posted by Ravi on January 21, 2002 at 11:44 PM

Unable to call servlet from JApplet embedded in IE5 with tomcat.

error:ctx() 400 r(/) null

my application requires JApplet Servlet communication.

I am trying to invoke a servlet from JApplet embedded in
a html file. I need to run my application in browser and
not with JFrames. now when i try to POST data from JApplet
the servlet nothing happens and the error 400 is returned
by the Tomcat and sometimes a socket write ...peer error
also comes not always.

My client Japplet program invokes the servlet this way

public void perform() {
Properties args = new Properties();
args.put("name","Pavan");
args.put("number","12345");
try {
URL url=new URL("http://localhost:8080/examples/servlet/TestServlet123");
URLConnection conn = url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
out.writeBytes(toEncodedString(args));
out.flush();
out.close();
}
catch (MalformedURLException e) {}
catch (IOException exc) {}
}

the servlet does this:

public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException
{
String name, number;
name = req.getParameter("name");
number = req.getParameter("number");
System.out.println(name);
System.out.println(number);
}

My application involes some complex logic based on this.
any body with any views on this problem may contact.

One other thing is that does JApplet can communicate with
servlet. if so i will be very thankful if anybody forwards some
sample code. all that i get from net is applet servlet communication
code.

its very urgent if any body can help out.


Ravi





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us