How do you send data from an applet to Servlet ? What are the steps involved in it ?

How do you send data from an applet to Servlet ? What are the steps involved in it ?

The applet can send a GET/POST request to the servlet by opening a servlet URL with a query string. For example : 

// servlet URL 
URL url = new URL(getCodeBase(), \"/MyServlet?name=ABC\");

// open a connection to the servlet
URLConnection servletCon = url.openConnection();
servletCon.setDoInput(true); // true, if we get data back

// get the input stream from the servlet
InputStream in = servletCon.getInputStream();

// read the response from the servlet
..................
..................
}


By:Jalees
Date:2016-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher