Results 1 to 4 of 4
- 01-20-2010, 04:34 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
- 01-20-2010, 04:55 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Using HttpClient?
Just a possibility.
- 01-20-2010, 05:58 PM #3
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Can you describe your real problem ?
What is app about and what server should do and what client should do?
Have you written that servlet?
Do you know how to use servlet container?
- 01-20-2010, 06:15 PM #4
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Got it.I have a servlet which runs under Tomact.
What I am looking is write a standalone program to call the servlet.
Looks like I got the solution and is working...
public static void main(String[] args) {
try {
System.out.println("Connecting to Servlet");
URL url = new URL("http://localhost/servlet/YourservletServlet");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
BufferedWriter out =
new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
out.write("username=name\r\n");
out.flush();
out.close();
BufferedReader in =
new BufferedReader( new InputStreamReader( conn.getInputStream() ) );
String response;
while ( (response = in.readLine()) != null ) {
System.out.println( response );
}
in.close();
}
catch ( MalformedURLException ex ) {
System.out.println("########"+ex);
ex.printStackTrace();
}
catch ( IOException ex ) {
System.out.println("@@@@@@@@@@@@@@"+ex);
ex.printStackTrace();
}catch(Exception e){
System.out.println("$$$$$$$$$$$$$$"+e);
e.printStackTrace();
}
}
Similar Threads
-
how to call servlet from the very first jsp page
By R O C K Y in forum Advanced JavaReplies: 6Last Post: 07-04-2012, 04:20 PM -
Rewrite as a function so it can call from main.
By thangli in forum New To JavaReplies: 2Last Post: 11-30-2008, 06:26 AM -
using a link to call servlet
By sijokunnappilly in forum Java ServletReplies: 3Last Post: 11-12-2008, 02:22 PM -
Call a main method from within a running program
By zoe in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:16 AM -
How to call JSP inside Servlet
By Swamipsn in forum Advanced JavaReplies: 0Last Post: 07-31-2007, 12:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks