File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes setting http Header using urlconnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "setting http Header using urlconnection" Watch "setting http Header using urlconnection" New topic
Author

setting http Header using urlconnection

Maggie Taylor
Greenhorn

Joined: Feb 14, 2006
Posts: 10
I have a servlet that recives http header information from a client program.

Now I have observed that when I assign a string value (including empty string ) in conn.addRequestProperty(), then the program works good. But, when I assign a null as any header value, then even the next header value displays a null even if I have assigned a value to it.


Here's a snippet from the client program:


A snippet from the servlet:


Can anybody help me in figuring out why this is happening ? I'm working on JDeveloper / Tomcat server.

Thanks.
Maggie
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
What exactly are you trying to accomplish by setting the property to null?
I would guess that you have broken the request header mechanism and an incomplete set of headers is sent - can you look at the actual headers transmitted with TCPMON or similar mechanism?
Bill
Maggie Taylor
Greenhorn

Joined: Feb 14, 2006
Posts: 10
Originally posted by William Brogden:
What exactly are you trying to accomplish by setting the property to null?


Thanks for replying Bill. I am testing the application for all different values - which include all these:
1)assigning a string as value
conn.addRequestProperty("file","abcd.xml");
2)assinging an empty String as value
conn.addRequestProperty("file","");
3)assinging a null as value
conn.addRequestProperty("file",null);

and the program is breaking down for the 3rd condition - showing null for next header value as well.

Maggie
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
Hello, It may be better not to set the header at all if you want the value to be null. Try something similar to:



Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting http Header using urlconnection