This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes Sending a String value to a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending a String value to a Servlet" Watch "Sending a String value to a Servlet" New topic
Author

Sending a String value to a Servlet

Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I've written a client/server application that does a POST from the java class to a servlet on my network. I'm sending a file through streams.
I need to be able to send a filename for this transfered file as well. I would normally just call get/setAttribute or get/setParams but they don't work in this situation. Does anyone have an idea of what I'm looking for? Thanks for your time.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12683
    
    5
Perhaps your client could set a request header with the URLConnection method addRequestProperty("filename", "somefilename")
and your servlet could read it with getHeader("filename")
(Have not tried this but it seems like it should work)
Bill


Java Resources at www.wbrogden.com
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I have be using the addRequestProperty method on the client, yet I haven't found a way to get that value in the server. I'll try getHeader. Thanks for your post!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sending a String value to a Servlet
 
Similar Threads
Sending email from JSP
How to send Image from the Applet to Servlet?
problem in jsp to servlet
Servlet and I/O
how to get the POST message?