Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

xml browser detection

Posted on 2002-03-19
4
324 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Merge 2 XML Files together 5 53
Viewing XML as a table on a Mac 3 171
Online tools to transform xml to excel using xsl 1 47
Eliminate additional border 1 22
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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