This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
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: 60788
    
  65

Why?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 60788
    
  65

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: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting http request headers
 
Similar Threads
sending data from HTML to APPLET
how to display records in html using servlets
How to set 'If-Modified-Since ' header
Servlets/HTTP
Access Headers