|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Application -> Servlet Communication
Hello!!
Can anybody help me with this? I have an aplication running on a Solaris 7 server (www.sol1.comm). This application needs to send a Vector to a Servlet on another server (www.sol2.comm). I want to use HTTP. Is there somone out ther who has a code example for this? Best reguards! |
|
#2
|
|||
|
|||
|
Is the application set up to make http requests? Do you understand how http works? Why do you want to use http? (firewall, etc?)
What is the "vector" exactly? Is it a Java Vector? How are you going to send it in http? |
|
#3
|
|||
|
|||
|
The only way to reach this machine is by HTTP.
Now I know that you can't send Objects over HTTP but variables. I just want som code examples on how you connect to a servlet with HTTP and then I can make it on my own. |
|
#4
|
|||
|
|||
|
http is stateless.
99% of any sample code you see about servlets is "connecting" with http. What is your application trying to send? (I don't need specifics, just a general idea) What is your app written in? To making an http request basically boils down to sending text to a listening port, typically 80. (Tomcat defaults to listening on 8080) If I have more info I can try to point you to a solution or at least in the right direction. What exactly is the servlet supposed to do when it gets the info? |
|
#5
|
|||
|
|||
|
My app is written in Java. I've got three variables (var1=dbname,var2=user,var3=password) that I want to send to a Servlet (Servlet1).
Servlet1 should (when reseiving the three varables) create a database in mysql. |
|
#6
|
|||
|
|||
|
It's as simple as making a client/server dialog. The client asks for the info via short, descriptive commands and the server sends the database info to the client.
It's almost kind of fun, it's so easy. Just don't forget to put your server socket and every socket it spawns into their own threads, otherwise you will end up with some thread issues and multi-connection problems.
__________________
Click here and wait. It's a kewl effect, trust me. |
|
#7
|
|||
|
|||
|
I have solved my problem!! I did it like this by using com.oreilly.servlet.
Application : public static void connectToServlet() { try { URL url = new URL("http://localhost:8080/servlet/Servlet"); HttpMessage msg = new HttpMessage(url); Properties props = new Properties(); props.put("database", "Test_database"); props.put("user", "Test_user"); props.put("password", "Test_password"); msg.sendPostMessage(props); DataInputStream result = new DataInputStream(new BufferedInputStream(in)); in.close(); } catch (Exception e) { e.printStackTrace(); } } |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Application -> Servlet Communication |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|