Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with HttpURLConnection

 
Tom Kowalski
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got strange problem,

I have got one servlet, which creates a file on my hard drive. It's working just fine, when I write http://localhost:8080/WI/Tester in webbrowser its creating this file.

I have got another servlet, which is making HttpURLConnection to the first servlet. But the first servlet doesnt create this file then, could somebody tell my why?

here is code:


I don't het any exception or anything...

Thanks...
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomasz Stachlewski wrote:I have got strange problem,

I have got one servlet, which creates a file on my hard drive. It's working just fine, when I write http://localhost:8080/WI/Tester in webbrowser its creating this file.

I have got another servlet, which is making HttpURLConnection to the first servlet. But the first servlet doesnt create this file then, could somebody tell my why?

here is code:


I don't het any exception or anything...

Thanks...


It is probably calling doGet of the servlet and you have written your code in doPost. You can check that by writing log statements
 
Tom Kowalski
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, problem is not here, I had doGet in firstServlet, but it didnt work, so I even replace it and Override service method. Here is the code:


But it is still not working. I was even trying to connect to this from normal Java Application, but still nothing...





I really don't know why... It should be so simple...
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open the input stream and read the response. That will establish the connection
 
Tom Kowalski
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heh, It's working, it turned out, that I should use connection.connect() but connection.getResponseCode() ... Strange :P But it's working, thanks anyway.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic