• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting http Header using urlconnection

 
Maggie Taylor
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, It may be better not to set the header at all if you want the value to be null. Try something similar to:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic