HELP!! HTML form -> Servlet -> Java Application
Hey everyone,
I need some help...
I want create something that works as follows:
- A client fills in an HTML-form
- when the form is submitted, it send its data to a servlet
- the servlet processes the received data and sends it to a java application running on an other computer which shows the processed data.
Does anyone have an idea how I can get this done? Is it possible using Tomcat-server or do I need an other one?
All hints are welcome!!
Tnx!
# 1
Hi......
What about the second application ? is it a web application? or stand alone application?
if it is a webapplication you can consider using URLConnection.
if it is stand alone application u can use Some thing like RMI.
check it to know how to send data from one application to another using URLConnection
http://www.theserverside.com/discussions/thread.tss?thread_id=40922#211833
take a look at HTTP Client component from apache. it can be used to post data from one application to another programatically
http://jakarta.apache.org/commons/httpclient/
Sudhir Nimavat
# 2
The code fragment below shows how to send a POST method to a servlet URL.
Write down this code in ur first servlet. to post data to some servlet in other application
// connect to the servlet
String location = "http://www.foo.com/servlet/servlet2";
URL testServlet = new URL( servletLocation );
URLConnection servletConnection = testServlet.openConnection();
// inform the connection that we will send output and accept input
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
// Don't use a cached version of URL connection.
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);
// Specify the content type that we will send binary data
servletConnection.setRequestProperty
("Content-Type", "<insert favorite mime type>");
// get input and output streams on servlet
. . .
// send your data to the servlet
. . .
Sudhir Nimavat