Hello!
I have a problem when I try to send some data (ObjectOutputStream) from a
servlet to an
applet.
This is my servlet code:
*************************************
public class SerializeQuestionsAction extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
try {
response.setContentType("application/x-java-serialized-object");
ObjectOutput toApplet=((ObjectOutput) response.getOutputStream());
Vector questions=(new ManageQuestionsService().chooseQuestions());
toApplet.writeObject(questions);
return mapping.findForward("success");
} catch (Exception e) {
return mapping.findForward("login-error");
}
}
}
***********************************
Applet Code:
public void doReceive() {
try {
URL urlServlet = new URL(getCodeBase(), "SerializeQuestions.do");
URLConnection con = urlServlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
ObjectInputStream inFromServlet = new ObjectInputStream(con.getInputStream());
Vector v=(Vector)inFromServlet.readObject();
for(int i=0;i<v.size();i++){
QuestionBean p=((QuestionBean)v.get(i));
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
************************************
When I try to run this an IOException occurs:
"java.io.IOException: Server returned HTTP response code: 500 for URL:
http://localhost:8080/project/SerializeQuestions.do "
Could you help me?What's wrong?
Thanks for your help