Reputation: 5920
How can I obtain the User-Agent header on JSP, using Struts 2?
Thanks in advance!
Upvotes: 0
Views: 1917
Reputation: 23587
If my assumptions are right you want to have the User-Agent header to deal with multiple view say desktop and mobile (only assumption)
There are various way to find details about use agent.One easy way came to my mind is simple JSTL
<c:set var="user-agent" value="${header['User-Agent']}" scope="session"/>
another is plain JSP code
String user_agent = request.getHeader("user-agent");
and if my assumption is right the best possible solution is to create an interceptors that can change the return code based on the user-agent of the client.
Any other inputs can be provided based on your requirements.
Upvotes: 1