This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes something related to request.getAttribute( Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "something related to request.getAttribute("user") in servlet" Watch "something related to request.getAttribute("user") in servlet" New topic
Author

something related to request.getAttribute("user") in servlet

ganesh pol
Ranch Hand

Joined: Apr 29, 2005
Posts: 151
i have client side code

HttpURLConnection connection connection = (HttpURLConnection) urlObject.openConnection();

connection.setRequestProperty("user-agent", userAgent);

which on servlet read as

request.getParameter("user-agent");

but now my requirements are changed

now i want to write client side code where my servlet will read it from

request.getAttribute("user-agent");

which method i must use so that my client side code will work
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The doc on getAttribute says:

Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute javax.servlet.request.X509Certificate can be used to retrieve information on the certificate of the client. Attributes can also be set programatically using setAttribute(java.lang.String, java.lang.Object). This allows information to be embedded into a request before a RequestDispatcher call.

This does not give me hope for your quest to set attributes on the client end of the request.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35438
    
    9
Where does the requirement to set attributes on the client side come from? As Stan points out, that is not possible.


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: something related to request.getAttribute("user") in servlet
 
Similar Threads
Use of HttpClient in Applet
difference between openConnection() and connect() methods
HttpURLConnection question on POST Method
How to display Ajax result on the same jsp page
setrequestheader() - User-Agent - no good?