how to send files from applet to jsp and jsp to applets?.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ranga_nath
Posted On:   Sunday, June 30, 2002 11:58 PM

i used one applet , in that i want to create new file and send to jsp or servlet.

at the same time i want sending file from servlet or jsp to applet.

Re: how to send files from applet to jsp and jsp to applets?.

Posted By:   k_strele  
Posted On:   Thursday, July 4, 2002 12:49 PM

You have to lay datastreams betwenn an Applet and the servlet:
Applet side:
public Hashtable readObject(URLConnection servlet)
{
Hashtable hashHelp=null;
try
{
BufferedInputStream inStream=new BufferedInputStream(servlet.getInputStream());
ObjectInputStream obIn=new ObjectInputStream(inStream);
hashHelp=(Hashtable) obIn.readObject();

}
catch(Exception e)
{
System.out.println("ERROR at AppLifeCycle readObject");
e.printStackTrace();
}
return hashHelp;
}
/**
* connects the Applet with its Datatransformationservlet ServBaseConnector
*/
private URLConnection getServletconnection(Serializable serial)
{
URLConnection help=null;
try
{
help=new URL(Linker.getServLink()+"ServBaseConnector"+"?format="+serial).openConnection();

}
catch(Exception e)
{
System.out.println("ERROR at AppLifeCycle getServleconnection");
e.printStackTrace();
}
return help;
}

Servletside:
public class ServBaseConnector extends HttpServlet implements Serializable
{
Serializable serHash=null;

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
try
{
serHash=BaseConnector.getLifeCycle();
ObjectOutputStream obOut=new ObjectOutputStream(response.getOutputStream());
obOut.writeObject(serHash);
ObjectInputStream obIn=new ObjectInputStream(request.getInputStream());
SelectedProductCategory.setCurrentCategory((String)obIn.readObject());
//System.out.println("Hello");
}
catch(Exception e)
{
System.out.println("ERROR at ServBaseConnector doGet:");
e.printStackTrace();
}

}
About | Sitemap | Contact