I believe the USR AGENT is passed in the request header. You should,
therefor be able to easily get a handle on it using your Action object.

To enumerate through all header names available:

java.util.Enumeration e = request.getHeaderNames();
while(e.hasMoreElements()) {
     String name = (String) e.nextElement();
     String.value = request.getHeader(name);
     System.out,println("ELEMENT = " + name + ", VALUE = " + value);
}

I think the user agent header name is just "User-Agent".  Try that.

- Cody






Sam Cheung <[EMAIL PROTECTED]> on 02/10/2002 12:37:49 AM

Please respond to Struts Users Mailing List
      <[EMAIL PROTECTED]>
To:   [EMAIL PROTECTED]
cc:
Subject:  Screen Flow based on UserAgent in Struts


Hi,

Is there a way to config Struts to forward a different
jsp based on the User Agent of the HTTP Request? I
would like to use the User Agent to identify the
client type (e.g. where desktop or a mobile phone) and
send out either HTML content or WML content.

I come up this idea, I am wondering if there are
better solutions:

Have a different forward name, different path for each
device type:
For example, in struts-config.xml

<action    path="/logoff"
type="org.apache.struts.webapp.example.LogoffAction">
     <forward name="successHTML"
path="/indexHTML.jsp"/>
     <forward name="successWML"
path="/indexWML.jsp"/>
</action>

And in the perform method of my action code, I have
something like:

if user agent is desktop
 return (mapping.findForward("successHTML"));
else
     return ((mapping.findForward("successWML"));


Thanks for any ideas.

Sam

__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>




----------------------------------------------------------------
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.   If you received
this in error, please contact the sender and delete the material from any
computer.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to