Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Lydia Hughes   on Dec 22 In Java Category.

  
Question Answered By: Fred Hicks   on Dec 22

There is different way of passing information from
front end application(Applet and application)to the
middlewares( such as servlet and jsp).
you can use a javabean as a data container and fill
your information in it and write it to stream by using
diiferent method such "writeobject" and in the other
side use"Readobject" and get the pointer to the
object .The following code  will help  you.

Client side:


try
{
URL url=new URL(urlStr);
URLConnection con=url.openConnection();
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
OutputStream out = con.getOutputStream();
ObjectOutputStream outStream = new
ObjectOutputStream(out);
outStream.writeObject(item);
outStream.close();
out.close();
InputStream in=con.getInputStream();
DataInputStream textStream=new DataInputStream(in);
textStream.close();
in.close();
}catch(Exception ex){
ex.printStackTrace() ;
}


server Side:

try{
InputStream in = request.getInputStream();
ObjectInputStream objStream;
objStream = new ObjectInputStream(in);
RequesterItem item= new RequesterItem();
item =(RequesterItem) objStream.readObject();
objStream.close();
in.close();

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on java application and url Or get search suggestion and latest updates.


Tagged: