Hi,
I am developing a web application where i use applet to fetch i/p from keyboard through applet and passs this as an attribute to jsp.
i dont knoe how to do that.Could you please help me?
Thanks
Printable View
Hi,
I am developing a web application where i use applet to fetch i/p from keyboard through applet and passs this as an attribute to jsp.
i dont knoe how to do that.Could you please help me?
Thanks
In the Applet and Servlet ( JSP ) communication, applet act as a client just like a browser and the Servlet or JSP act as a server.
Now, the applet can send GET or POST requests to the servlet or JSP and in turn receive data from them.
You just have to create a URLConnection from the URL of the servlet and write or read from the Output/InputStream.
For eg.
in your applet, create a URLConnection object like this: -
URL url = new URL(getCodeBase(), "<servlet>" )
URLConnection connection = url.openConnection();
now, read or write to the servlet: -
connection.setDoInput(true);
InputStream istream = connection.getInputStream();
or
connection.setDoOutput(true);
OutputStrem ostream = connection.getOutputStrem();
In case of reading and writing Objects, you can open a ObjectInputStream or ObjectOutputStream. But remember to set the Content-Type of the Output stream while writing to the servlet to the appropriate type.
I think this much information will get you started! :WAVE: