Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

xml browser detection

Posted on 2002-03-19
4
Medium Priority
?
331 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
3 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

877 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