• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

setting http Header using urlconnection

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic