aspose file tools
The moose likes Servlets and the fly likes Calling Servlet from Java application Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Calling Servlet from Java application" Watch "Calling Servlet from Java application" New topic
Author

Calling Servlet from Java application

sreedhar Lackka
Ranch Hand

Joined: Jul 05, 2008
Posts: 154
Hi All,
Thanks.
I am unable to call my servlet from my stand alone java application
Following is the code which I used,



Please help me ....
It is great if you could give example links which are wokring.

Regards,
Sree
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What happens when you try? Any error messages?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35258
    
    7
How is this code working or not working? What do you expect to happen if you instruct the connection to perform neither input nor output?


Android appsImageJ pluginsJava web charts
sreedhar Lackka
Ranch Hand

Joined: Jul 05, 2008
Posts: 154
Thanks for your reply.
Even I tried with con.setDoOutput(true); but nothing is happening.
Just I have written one System.out.println() in my Servlet when I run the above program the statement which is written in SOP is not printing.
Could you please give me any example.
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Is your server which is on IP 12.234.26.2, running on port 80 or some other port??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
sreedhar Lackka
Ranch Hand

Joined: Jul 05, 2008
Posts: 154
Yes it is running on 9080 port.
In URL I tried with :9080 also, but not helpful.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You aren't reading the output at all. Get the InputStream and read it.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
Why do you setDoInput and setDoOutput to false???

Did you actually read the URLConnection and HttpURLConnection JavaDocs?

If you are going to read an input stream from the response, doInput needs to be true.

Bill


Java Resources at www.wbrogden.com
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To help you one step further:

http://google.com/search?q=urlconnection+tutorial+site:sun.com
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Calling Servlet from Java application
 
Similar Threads
Servlet Communication using java.net
Query about event for refresh button??
Connecting to the webserver from simple java program with main method
HttpURLConnection question on POST Method
Any way to overcome Circular Redirect using HttpClient 4.1.1