wood burning stoves 2.0*
The moose likes Servlets and the fly likes Connecting a Java application to a Servlet/JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Connecting a Java application to a Servlet/JSP" Watch "Connecting a Java application to a Servlet/JSP" New topic
Author

Connecting a Java application to a Servlet/JSP

Kavita Ghia
Ranch Hand

Joined: Oct 10, 2000
Posts: 91
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

Joined: Sep 14, 2000
Posts: 264
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
 
subject: Connecting a Java application to a Servlet/JSP
 
Similar Threads
Persistent data in servlets
networking
Applet doesn't establish JDBC connection
Pls help me connect java GUI to flex expert system shell
JDBC using Applets