• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet on the Internet  RSS feed

 
Xinyi Zhang
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet, when it run on local machine and LAN, my client program can access it easily by OutputStream and InputStream. But when it run on internet, for example the URL is http://<myIP ort>/myProject/myServlet, client program can not access it. The servlet address is correct, I can access it from web browser.
the client program is:
String myURL="http://<myIP ort>/myProject/myServlet";
try {
URL url=new URL(myURL);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream(); // throws exception here
....
Can anybody help. How to make the servlet work on the internet?
Thanks.
 
Marty Hall
Author
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me see if I understand what you are saying. You put a servlet online at http://someHost/someURL.
  • From someHost:

  • [list] Typing in http://someHost/someURL works.
  • Running your program that uses URLConnection works.


  • From someOtherHost:
  • Typing in http://someHost/someURL works.
  • Running your program that uses URLConnection fails.


  • [/LIST]
    Is that right? If so, the only thing that occurs to me off the top of my head that might account for it is if your program is an applet. I got the impression that it is a standalone application, but if it was an applet, then the browser security restrictions could easily account for this.
    If my understanding of the situation is wrong, maybe you could clarify the situation. If my understanding is right and your program is not an applet, maybe you can post the full error message?
    Cheers-
    - Marty
     
    Kyle Brown
    author
    Ranch Hand
    Posts: 3892
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Here's a guess -- check your Browser configuration and see if you are using a proxy server to connect to the internet. If so, there's your problem; the client program doesn't know the proxy address and is getting blocked.
    Kyle
     
    Don't get me started about those stupid light bulbs.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!