Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

send data to jsp  RSS feed

 
johny sill
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI ,

my swing is
String str="http://localhost:8080/sampleapp/connect.jsp";
String msg="data";
URL url=new URL(str);
URLConnection con =url.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(true);
OutputStream os = con.getOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(msg);
oos.flush();
oos.close();

AppletContext context=getAppletContext();
context.showDocument(url,"_blank");


in my jsp i getting this data like this

<%! String transmitContent; %>
<%

try{
ObjectInputStream inputFromApplet = new ObjectInputStream(request.getInputStream());
transmitContent = (String) inputFromApplet.readObject();
out.println(transmitContent);
}
catch(Exception e)
{
System.out.println("kal"+e);
}
%>

but i not getting value

is there any problem

Help me,

Thanks in advance
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're calling the JSP two times:

- once using url.getConnection, where you send the data, but ignore the response, and

- once using context.showDocument, where you show the result of the JSP without sending it any data (showDocument will open its own connection to the URL).

This problem is not related to Swing, though - moving it to our Internet Protocols forum...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!