File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting a Java application to a Servlet/JSP

 
Kavita Ghia
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
I am attempting to make an application in servlets similar to messenger and my problem is how do I connect the clients machine with the servlet once he logs in,since the messengers are basically downloaded products and once u logon and connect your browser gets invoked.
Can anyone help me.Thanking all of u in advance.bye.
 
Pranav Jaidka
Ranch Hand
Posts: 264
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi kavita
1> try creating a URL object with the url of the servlet.
then Using a URLConnection or an HTTPConnection object in which you can pass the url as parameter
for Ex
con = url.openConnection();

2> If the above succeeds (it should if your URL is correct).
then your work is done.
3> do the following as per your rewuirements....
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
where con is the connection object.
4>now the final stage involves the obtaining of the
input and output streams for the Connection
use
inputFromServlet = new ObjectInputStream(con.getInputStream());
outputToServlet = new ObjectInputStream(con.getInputStream());
5> your program is ready ....after this you can use the streams to pass the values....(you need to have corresponding streams at the servlet end)
and dont forget to flush the streams to get results at the other end.
Hope this is good enough for you ...in case of any doubts you can mail me at pranav@infics.com
good luck

inputFromServlet = new ObjectInputStream(con.getInputStream());
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic