problem in applet to servlet communication
hi every one ,
i have a applet code which sends data to the servlet through URL connection.then that servlet takes this data and creates required file(.doc/.rtf/.xls/.pdf) using set headers.
my applet code is as follows.
public class SampleApplet extends JApplet
{
public void init()
{
try{
URL url = new URL("http://localhost:8080/App1/Servlet1");
URLConnection urlconnection =url.openConnection();
urlconnection.setDoOutput(true);
urlconnection.setUseCaches(false);
urlconnection.connect();
OutputStream os=urlconnection.getOutputStream();
OutputStreamWriter osw=new OutputStreamWriter(os);
BufferedWriter bw=new BufferedWriter(osw);
bw.write("place this data in file");
}
}
}
My servlet class is as follows
public class Servlet1 extends HttpServlet
{
public void service(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
PrintWriter out=response.getWriter();
InputStream is=request.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is));
response.setContentType("application/vnd.ms-excel");
response.setHeader ("Content-Disposition", "attachment; filename=\"Sample.xls\"");
response.setHeader("Cache-Control", "no-cache");
out.write(br.readLine());
}
}
when i call this servlet from html file it works fine creates a xls file and opens the file down load dialog .
but when i call this servlet from the applet the file is not creating and file download dialog is not opening.
can anybody solve my problem?
please help me.

