Solved

xml browser detection

Posted on 2002-03-19
4
322 Views
Last Modified: 2008-02-01
hi,

as a total newbie to xml, I'm wondering how to detect a browser type in an xml file. The varianble called treeview.xsl should change according to the browser type (ie.xsl / ns.xsl) The script looks like this;

***********
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
  <display-name>hmg</display-name>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>application</param-name>
      <param-value>ApplicationFormResources</param-value>
    </init-param>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>validate</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
   
  </servlet>
  <servlet>
    <servlet-name>content</servlet-name>
    <servlet-class>no.cellnetwork.hmg.contentmanagement.servlets.ShowContentServlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>initservlet</servlet-name>
    <servlet-class>no.cellnetwork.hmg.init.servlets.InitServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet>
    <servlet-name>treeview</servlet-name>
    <servlet-class>no.cellnetwork.hmg.tree.servlets.TreeViewServlet</servlet-class>
    <init-param>
      <param-name>xslurl</param-name>
      <param-value>http://localhost/eportal/hmg/xsl/treeview.xsl</param-value>
    </init-param>
    <init-param>
      <param-name>xslurlmyprofile</param-name>
      <param-value>http://localhost/eportal/hmg/xsl/myprofile.xsl</param-value>
    </init-param>
    <init-param>
      <param-name>defaultrepository</param-name>
      <param-value>public</param-value>
    </init-param>
  </servlet>
  <servlet>
    <servlet-name>iconservlet</servlet-name>
    <servlet-class>no.cellnetwork.hmg.icon.servlets.IconServlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>imageservlet</servlet-name>
    <servlet-class>no.cellnetwork.hmg.image.servlets.ImageServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>content</servlet-name>
    <url-pattern>/jsp/content/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>treeview</servlet-name>
    <url-pattern>/jsp/treeview/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>imageservlet</servlet-name>
    <url-pattern>/jsp/imageservlet/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>initservlet</servlet-name>
    <url-pattern>/init</url-pattern>
  </servlet-mapping>  
  <servlet-mapping>
    <servlet-name>iconservlet</servlet-name>
    <url-pattern>/jsp/iconservlet/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <session-config>
    <session-timeout>30</session-timeout>
  </session-config>
  <taglib>
    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/struts</taglib-uri>
    <taglib-location>/WEB-INF/lib/struts.jar</taglib-location>
  </taglib>
</web-app>
***************

Any ideas greatly appreciated!

Regards,

Erik
0
Comment
Question by:gooroo
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 100 total points
ID: 6879786
Look at the user agent in the servlet or jsp:

<%!
public final static int IE = 0;
public final static int NETSCAPE = 1;
public final static int WML = 2;

public int getBrowser(HttpServletRequest request) {
   String accept = request.getHeader("ACCEPT");
   if (null != accept && -1 !=
accept.indexOf("wml")) {
     return WML;
   }
   String agent = request.getHeader("USER-AGENT");
   if (null != agent && -1 !=
agent.indexOf("MSIE")) {
     return IE;
   }
   return NETSCAPE;
}
%>

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 8647674
Please finalize this?
Thanks
Michel
PS: Please do not respond with a "C" Grade to get rid of the question
0
 
LVL 9

Expert Comment

by:sparkplug
ID: 8730672
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[Accept mplungjan's comment as answer.]
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

>S'Plug<
EE Cleanup Volunteer
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
surrogate key in database world 6 86
PHP and Soap 3 51
msxml3.dll error '80072efd' A connection with the server could be not established 8 39
SQL Result Set to XML 4 36
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now