views:

196

answers:

3

I have a servlet hosted in the glassfish server. i want to communicate with it using telnet to understand what is going on behind the scenes when using html form get method.

What should i give in the Host field of the HTTP request?

Get /WebApplication1/NServlet HTTP/1.1
Host: localhost

If i want to send custom properties in the HTTP request as below, is it possible to extract their value using request.getAttribute() method.

Get /WebApplication1/NServlet HTTP/1.1
Host: localhost
Custom-Attribute: xyz

Another doubt is that is javax.servlet package not a part of java SE sdk. i had to install java ee to get it running.

A: 

Based on your question, I don't there's enough information for anyone to answer you. Tomcat/Jetty/etc are basically web servers that contain servlets (and therefore JSP/JSF/Wicket etc etc) processors for dynamically generating content. So, what is it you're trying to figure out, and why?

Jim Barrows
I want to use HTTP protocol for my application. just as HTTP has content-length, host properties i plan to send configuration parameters to the server from my client. so i could do request.getParameter("parameter-name"); is it the right way to use http protocol for my application or should i send my configuration parameters in the content portion of http request.
iamrohitbanga
So you're trying to configure and manage an application via http? If it's a java application, there's JMX which can do it much easier. If it's not.. HttpClient.What you're trying to do sounds like doing it the hard way.
Jim Barrows
A: 

If you want to use HTTP for your protocol (as you've suggested in your comments), check out HttpClient. As the name suggests, it's the client-side of the client/server HTTP implementation, and it should be relatively easy to determine what to set on the client side such that you see it on the server.

There's a great tutorial here. I would perhaps get a simple page working in the servlet first, and check it via the browser, and then implement the client side.

Brian Agnew
+1  A: 

The Host field is just the hostname part of the URL, e.g. Host: google.com for http://google.com/

Custom-Attribute: xyz would be exposed in the HttpServletRequest using getHeader(), not getAttribute().

skaffman