This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes setting http request headers Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "setting http request headers " Watch "setting http request headers " New topic
Author

setting http request headers

Suma Chandran
Greenhorn

Joined: Feb 12, 2006
Posts: 5
Hi,

I have deployed a servlet using Tomcat. I access this servlet using a html page where I type in the 2 parameters - id and name. I get these parameters in my servlet using "request.getParameter()".

Instead of using a html page, I would like to set "id" and "name" as http headers, so that I can access them in the servlet using "request.getHeader()" ? How can I go about doing that?

thanks.
Suma.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56191
    
  13

Why?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Suma Chandran
Greenhorn

Joined: Feb 12, 2006
Posts: 5
Well, some requirements which I have been given. I am perturbed about how I should be working on this ? Any suggestions ?

I would also like to add that, the servlet does some processing and displays the results in a jsp page. So as of now

html => servlet => jsp

I would like the servlet to get the header info and then proceed with the rest of the processing.
[ March 23, 2006: Message edited by: Suma Chandran ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56191
    
  13

There is no way for an HTML file to set the request headers. Your requirements cannot be met. Why on earth do they want to pass request parameters in the header?
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489


Why on earth do they want to pass request parameters in the header?


That sounds more probably like Suma's solution to the requirements rather than the actual requirement itself. Suma, why don't you post the requirement itself and somebody here would suggest a different approach to solve it.

cheers,
ram.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
I have heard occasional objections to passing parameters in the URL of a GET request. Usually, changing the request to POST (which then sends the parameters in the body of the request) is enough to convince doubters.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: setting http request headers
 
Similar Threads
Access Headers
how to display records in html using servlets
Servlets/HTTP
How to set 'If-Modified-Since ' header
sending data from HTML to APPLET