Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP response lost - see instead index.html page  RSS feed

 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I developed a simple servlet using Netbeans IDE - and deployed it to a standalone Tomcat running as Windows service. I'm testing an HTTP POST request using the HTTP Resource Test Firefox plugin. Response processing in the servlet looks like this:

When I do the POST (of some XML) I want to see the output from the Servlet's response processing out.println statements via response.getWriter. Instead, an index.html (from the Netbeans project's WEB-INF folder) is displayed? How do I fix this so I get see the response that I am writing out via response.getWriter.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you verified that your servlet is getting called in the first place?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this code actually run? Have you put a System.out.println statement in there and seen its output in the log files? How is it mapped? Is this code in the doPost method?
 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the code runs: I'm testing with HTTP Resource test plugin in Firefox - I specify POST, and paste in my message body and submit. The plugin prints the server response (which identifies Apache Tomcat among other objects) and shows the message body. As you know, the message body does not contain the response - but the static content of an index.html file.
The code for the servlet follows:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see how that proves that your servlet is being addressed. Have you tried Ulf's logging approach?
 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

Right, the servlet code doesn't prove that the servlet has been run. I included the servlet code to show what method contained what in response to the question. I specified that I tested with HTTP Resource Test Firefox plugin with results that verified that that Tomcat ran the servlet - The servers response header = :
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Accept-Ranges: bytes
Etag: W/"490-1401380814000"
Last-Modified: Thu, 29 May 2014 16:26:54 GMT
Content-Type: text/html
Content-Length: 490
Date: Fri, 30 May 2014 14:16:09 GMT

The server's response message body = :

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Welcome Page! Servlet to process XML</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>yeo! what's happening dude?</div>
</body>
</html>


I don't know if this officially constitutes proof that the servlet ran, but I don't see how else the Resource Test could know about Apache-Coyote/1.1 unless it ran the servlet.

I will deploy a logging version and test shortly.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Last time I'll ask: have you tried using Ulf's log gin approach. Just looking at the wrong response isn't going to help anybody help you.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You code is working, I think you misunderstand how HTTP Resource Test works. You are sending the POST from HTTP Resource Test, so it IS the browser in this case. The output will not show up in Firefox, instead, the output of the servlet is returned to the "Body" window in the "Server Response" section.

I'm not very familiar with this add-on and honestly I don't see the benefit of it. If you haven't used Firebug, run, don't walk, and get it installed. The responses will show up in the browser as you expect and you will be able to see the headers, the POST payload, and the servers response all in the Firebug tabs.
 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't ask again. I replied in my last post: "I will deploy a logging version and test shortly" - I'll post again when I get System.out.println results;
 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for that response - J Kevin Robbins,

I thought I did understand Resource Test - The output I posted (content of static.index.html file) was copied from the Resource Test servlet response body section of Resource Test: Here it is again.

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Welcome Page! Servlet to process XML</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.
</head>
<body>
<div>yeo! what's happening dude?</div>
</body>
</html>


This certainly is not what I wanted to see returned from the server.

However I will look into FireBug right after I try to find my System.out.println log.">
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firebug is cool, but modern versions of Firefox come with a built-in debugger. Also, I personally find the Chrome Dev Tools easier to use.

In any case, this seems to be one more nail in the coffin of IDEs getting the way of development rather than helping it along.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!