on 07-19-2005 9:48 AM
Hi,
Is there a way to call a servlet from a Java standalone class (of course I want to pass to the servlet parameters and to retrieve results from the servlet) ?
Thanks a lot.
Regards.
Hi,
From your requirement I understand that you wanted to send objects at runtime from java class to servlet.In Java technology this can be acheieved by a concept called "Serialization".
Please refer to the java docs on
java.io.serialization
You will get better idea.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
I think you can do this.
Jus try some thing like this inside your stand alne java class :-
URL test = new URL(servletURL);
where servletURL should contain the complete URL of your servlet
test.openStream();
I suggest you check more on URL class in Java docs.
Hope it helps you a bit.
Regards,
Guru
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guru,
Thanks for the reply.
In my serlvet I wrote:
response.getWriter().write("in the doGet method");
In my Java class, I wrote the following :
URL url = new URL("http://server:port//Servlet1/theservlet");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
I do get the String "in the doGet method".
But what if I wanted to send Objects ?
Is there a way ?
I cannot user session of course....
Any idea will be welcome.
Thanks in advance.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.