Solved

xml browser detection

Posted on 2002-03-19
4
326 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
[X]
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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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