• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ganesh pol
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where does the requirement to set attributes on the client side come from? As Stan points out, that is not possible.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic