Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cookie and struts

Status
Not open for further replies.

maxpower1

Programmer
Jul 29, 2001
488
US
does anyone know how to readwrite a cookie through action form? I need to get the computer name the request is coming from. Hence, in the beginnning, I need to set the computer name using a persistent cookie.

thanks

~za~
You can't bring back a dead thread!
 
I need to do something similar ... on a login page, prepopulate the username field with a cookie value. I'm assuming that it would be better do it in the ActionForm class instead of the JSP. Any ideas on how to reference the HttpServletRequest object from the ActionForm class ?
 
You could do it in either the Action class or the ActionForm class.

The Action.execute() has the HttpServletRequest object in its parameters, as does the ActionForm.validate() and ActionForm.reset() ...
 
You can read cookie in ActionForm via HttpServletRequest, but I don't think you can write cookie in ActionForm as I don't see a way you can obtain a HttpServletResponse in ActionForm.

You can certainly write cookie in Action Class.

My guess is you want to set a cookie if validation failed. One solution is to set a cookie bean to the HttpServletRequest object in the ActionForm. When it forward to the JSP page after validation failed, you can then write the cookie in the JSP if a cookie bean is found.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top