Applet Not Sending object to Servlet.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alfred_Wong
Posted On:   Wednesday, December 4, 2002 06:07 AM

Hello, I was wondering if anybody could help me because for some strange reason my applet is not sending the object to my servlet through doPost(). I tried calling the servlet from the normal IE address bar and it works but it doesn't seem to work when I do it through the applet. I know this because I tried putting println statments in the doPost method in my servlet and looked at the catalina.out file and it doesn't seem to be there. So any help would be appreciated. Here is the code: //Applet Code try { URL inputservlet = new URL(getCodeBase() + servletpath1); URLConnection servletconnection = inputservlet.openConnection(); servletconnection.setDoOutput   More>>

Hello,



I was wondering if anybody could help me because for some strange reason my applet is not sending the object to my servlet through doPost(). I tried calling the servlet from the normal IE address bar and it works but it doesn't seem to work when I do it through the applet. I know this because I tried putting println statments in the doPost method in my servlet and looked at the catalina.out file and it doesn't seem to be there. So any help would be appreciated.



Here is the code:

			
//Applet Code
try
{
URL inputservlet = new URL(getCodeBase() + servletpath1);
URLConnection servletconnection = inputservlet.openConnection();

servletconnection.setDoOutput(true);
servletconnection.setDoInput(true);
servletconnection.setUseCaches(false);
servletconnection.setRequestProperty("Content-Type", "application/octet-stream");

outputtoservlet = new ObjectOutputStream(servletconnection.getOutputStream());
outputtoservlet.writeObject(input);

outputtoservlet.flush();
outputtoservlet.close();
log("Complete.");
}
catch(Exception e)
{
log(e.toString());
}

//Servlet Code
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
{
ObjectInputStream inputfromapplet = null;
ParamObject theinput = null;
String hostname = "";
String startdate = "";
String stopdate = "";
String interfaces = "";
StringTokenizer filenumbers;
try
{
inputfromapplet = new ObjectInputStream(request.getInputStream());
theinput = (ParamObject)inputfromapplet.readObject();

hostname = theinput.getSelectedHostname();
startdate = theinput.getSelectedStartDate();
stopdate = theinput.getSelectedStopDate();
interfaces = theinput.getSelectedInstances();

data = db2.requestInfo(hostname, startdate, stopdate, interfaces);
filenumbers = new StringTokenizer(interfaces, " ,
f ");

HttpSession session = request.getSession(true);
session.setAttribute("data", data);
session.setAttribute("filenumbers", filenumbers);
gotoPage("/graph.jsp", request, response);
}
catch(Exception e)
{
e.printStackTrace();
}
}




Any kinda of feed back would be good.

Thank you.    <<Less
About | Sitemap | Contact