By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

Applet-Servlet Problem(Please Help)......

P: n/a
When I click the Button in Applet , I want it open a Dialog asking for
the excel to open/save etc... It doesnt happen why...

Now it doesnt create the excel file Why....
My Applet code is
------------------------------------------------------------------------------
URL url =new URL("http://localhost:8080/portal/servlet/com.kbs.framework.client.gui.ReportServlet");

HttpURLConnection servletConnection =
(HttpURLConnection)url.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);

servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setRequestMethod("POST");
servletConnection.setRequestProperty("Content-type","application/octet-stream");

ObjectOutputStream outStream =
new ObjectOutputStream(servletConnection.getOutputStre am());
outStream.writeObject(command);
outStream.flush();
outStream.close();

System.out.println("MY RESULT IN APPLET");
InputStream instr = servletConnection.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
String result = (String) inputFromServlet.readObject();
inputFromServlet.close();
instr.close();
------------------------------------------------------------------

SERVLET CODE
--------------------------------------------------------------------
public void performTask(javax.servlet.http.HttpServletRequest
request,javax.servlet.http.HttpServletResponse response)
{
response.setContentType("application/vnd.ms-excel");
PrintWriter out = response.getWriter();
String fileName = "temp" + Long.toString(System.currentTimeMillis())
+ ".xls";
response.addHeader("Content-Disposition", "inline; filename=\"" +
fileName
+ "\"");
InputStream in = request.getInputStream();
ObjectInputStream inputFromApplet = new ObjectInputStream(in);
String command = (String) inputFromApplet.readObject();
String result = submitQuery(command);
System.out.println("RESULT" + result);
out.println(command);
out.close();
----------------------------------------------------------------------------
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.