| Author |
Problem with HttpURLConnection
|
Tom Kowalski
Ranch Hand
Joined: Feb 17, 2009
Posts: 72
|
|
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...
|
SCJP, SCWCD, OCUP
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6588
|
|
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
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Tom Kowalski
Ranch Hand
Joined: Feb 17, 2009
Posts: 72
|
|
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
Joined: Feb 24, 2006
Posts: 6588
|
|
|
Open the input stream and read the response. That will establish the connection
|
 |
Tom Kowalski
Ranch Hand
Joined: Feb 17, 2009
Posts: 72
|
|
|
Heh, It's working, it turned out, that I should use connection.connect() but connection.getResponseCode() ... Strange :P But it's working, thanks anyway.
|
 |
 |
|
|
subject: Problem with HttpURLConnection
|
|
|