[hmath-commits] org.hmath.server/WEB-INF/src/org/hartmath/server/taglib MathSniffer.java,NONE,1.1 Br
Status: Pre-Alpha
Brought to you by:
jsurfer
|
From: Klaus H. <js...@us...> - 2004-03-20 14:45:53
|
Update of /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/taglib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18425/WEB-INF/src/org/hartmath/server/taglib Modified Files: BrowserTag.java BrowserSniffer.java HeaderTag.java Added Files: MathSniffer.java Log Message: misc changes Index: BrowserTag.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/taglib/BrowserTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BrowserTag.java 12 Mar 2004 20:50:50 -0000 1.2 --- BrowserTag.java 20 Mar 2004 14:35:54 -0000 1.3 *************** *** 9,24 **** import javax.servlet.jsp.tagext.BodyTagSupport; - import org.snipsnap.app.Application; - /** ! * Java JSP taglib interface to detect the clients browser type ! * */ public class BrowserTag extends BodyTagSupport { private String fType; ! private String fContent = null; ! public static String MSIE = "msie"; ! public static String NETSCAPE = "netscape"; ! /** * Returns "msie" for Internet Explorer; "netscape" otherwise --- 9,22 ---- import javax.servlet.jsp.tagext.BodyTagSupport; /** ! * Java JSP taglib interface to detect the clients browser type ! * */ public class BrowserTag extends BodyTagSupport { private String fType; ! // private String fContent = null; ! public static String MSIE = "msie"; ! public static String NETSCAPE = "netscape"; ! /** * Returns "msie" for Internet Explorer; "netscape" otherwise *************** *** 27,84 **** * @return */ ! public static String getBrowserType(HttpServletRequest request) { ! String userAgentString = request.getHeader("User-Agent"); ! String browser = new String(""); ! if (userAgentString != null) { ! if ((userAgentString.indexOf("MSIE") == -1) && (userAgentString.indexOf("msie") == -1)) { ! browser = NETSCAPE; ! } else { ! browser = MSIE; ! } ! ! } ! return browser; ! } ! private String getBrowserVersion(HttpServletRequest request) { ! String userAgentString = request.getHeader("User-Agent"); ! String version = new String(""); ! if (userAgentString != null) { ! if ((userAgentString.indexOf("MSIE") == -1) && (userAgentString.indexOf("msie") == -1)) { ! int verPos = userAgentString.indexOf("/"); ! if (verPos != -1) ! version = userAgentString.substring(verPos + 1, verPos + 5); ! } else { ! String tempStr = userAgentString.substring(userAgentString.indexOf("MSIE"), userAgentString.length()); ! version = tempStr.substring(4, tempStr.indexOf(";")); ! } ! } ! return version; ! } public int doAfterBody() throws JspException { // log("doPost"); ! BodyContent body = getBodyContent(); ! JspWriter out = body.getEnclosingWriter(); ! String bodyData = body.getString(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ! // HttpSession session = request.getSession(true); ! String browserType = getBrowserType(request); ! // System.out.println(browserType); ! // System.out.println(fType); ! if (browserType.equalsIgnoreCase(fType)) { ! if (fContent != null) { ! pageContext.getResponse().setContentType(fContent+"; "+Application.get().getConfiguration().getEncoding()); } - try { - out.print(bodyData); - } catch (IOException e) { - } } return SKIP_BODY; } /** * @return --- 25,105 ---- * @return */ ! // public static String getBrowserType(HttpServletRequest request) { ! // String userAgentString = request.getHeader("User-Agent"); ! // String browser = new String(""); ! // if (userAgentString != null) { ! // if ((userAgentString.indexOf("MSIE") == -1) && (userAgentString.indexOf("msie") == -1)) { ! // browser = NETSCAPE; ! // } else { ! // browser = MSIE; ! // } ! // ! // } ! // return browser; ! // } ! // private String getBrowserVersion(HttpServletRequest request) { ! // String userAgentString = request.getHeader("User-Agent"); ! // String version = new String(""); ! // if (userAgentString != null) { ! // if ((userAgentString.indexOf("MSIE") == -1) && (userAgentString.indexOf("msie") == -1)) { ! // int verPos = userAgentString.indexOf("/"); ! // if (verPos != -1) ! // version = userAgentString.substring(verPos + 1, verPos + 5); ! // } else { ! // String tempStr = userAgentString.substring(userAgentString.indexOf("MSIE"), userAgentString.length()); ! // version = tempStr.substring(4, tempStr.indexOf(";")); ! // } ! // } ! // return version; ! // } public int doAfterBody() throws JspException { // log("doPost"); ! HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ! MathSniffer bd = MathSniffer.getBrowserDetection(request); ! int browserId = bd.getBrowserId(); ! String browserType = getType().toLowerCase(); ! if (browserType.length() >= 3 && browserType.length() <= 10) { ! int index = 0; ! switch (browserType.length()) { ! case 3 : ! if (browserType.equals("xml") && browserId == MathSniffer.XMLID) { ! // "Gecko"; ! printBody(); ! } else if (browserType.indexOf("css") != (-1) && browserId == MathSniffer.CSSID) { ! // "Opera" "Safari" ! printBody(); ! } ! break; ! case 6 : ! if (browserType.indexOf("others") != (-1) && browserId == MathSniffer.OTHERSID) { ! // all other cases ! printBody(); ! } ! break; ! case 10 : ! if (browserType.equals("mathplayer") && browserId == MathSniffer.MATHPLAYERID) { ! // "MSIE" + "Mathplayer" ! printBody(); ! } ! break; } } return SKIP_BODY; } + private void printBody() { + BodyContent body = getBodyContent(); + JspWriter out = body.getEnclosingWriter(); + try { + out.print(body.getString()); + } catch (IOException e) { + + } + } /** * @return *************** *** 95,111 **** } ! /** ! * @return ! */ ! public String getContent() { ! return fContent; ! } ! ! /** ! * @param string ! */ ! public void setContent(String string) { ! fContent = string; ! } } --- 116,132 ---- } ! // /** ! // * @return ! // */ ! // public String getContent() { ! // return fContent; ! // } ! // ! // /** ! // * @param string ! // */ ! // public void setContent(String string) { ! // fContent = string; ! // } } Index: BrowserSniffer.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/taglib/BrowserSniffer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BrowserSniffer.java 12 Mar 2004 20:50:50 -0000 1.1 --- BrowserSniffer.java 20 Mar 2004 14:35:54 -0000 1.2 *************** *** 62,66 **** public static final String MSPIE = "MSPIE"; public static final String NETSCAPE = "Mozilla"; ! public static final String MOZILLA = "Gecko"; public static final String SAFARI = "Safari"; public static final String KONQUEROR = "Konqueror"; --- 62,66 ---- public static final String MSPIE = "MSPIE"; public static final String NETSCAPE = "Mozilla"; ! public static final String GECKO = "Gecko"; public static final String SAFARI = "Safari"; public static final String KONQUEROR = "Konqueror"; *************** *** 71,75 **** public static final int MSPIEID = 4; public static final int NETSCAPEID = 5; ! public static final int MOZILLAID = 6; public static final int SAFARIID = 7; public static final int KONQUERORID = 8; --- 71,75 ---- public static final int MSPIEID = 4; public static final int NETSCAPEID = 5; ! public static final int GECKOID = 6; public static final int SAFARIID = 7; public static final int KONQUERORID = 8; *************** *** 260,267 **** this.browserId = KONQUERORID; this.version = parseVersion(KONQUEROR); ! } else if (userAgent.indexOf(MOZILLA) != -1) { // "Revision builds"/Netscape ab 6.0(???) // this.browser = MOZILLA; ! this.browserId = MOZILLAID; this.version = parseVersion("rv:"); --- 260,267 ---- this.browserId = KONQUERORID; this.version = parseVersion(KONQUEROR); ! } else if (userAgent.indexOf(GECKO) != -1) { // "Revision builds"/Netscape ab 6.0(???) // this.browser = MOZILLA; ! this.browserId = GECKOID; this.version = parseVersion("rv:"); *************** *** 468,472 **** */ public boolean isModernMozilla() { ! return (browserId == MOZILLAID); } --- 468,472 ---- */ public boolean isModernMozilla() { ! return (browserId == GECKOID); } *************** *** 478,482 **** */ public boolean isMozilla() { ! return (browserId == MOZILLAID); } --- 478,482 ---- */ public boolean isMozilla() { ! return (browserId == GECKOID); } --- NEW FILE: MathSniffer.java --- package org.hartmath.server.taglib; /* * * Copyright (C) Johannes Lietz, joh...@da... Modified by Klaus Hartlage * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ import java.io.Serializable; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; /** * detect how the browser can show math documents */ public class MathSniffer implements Serializable { static final long serialVersionUID = 7731753920913450421L; public static final int OTHERSID = 1; public static final int CSSID = 2; public static final int XMLID = 3; public static final int MATHPLAYERID = 4; // MSIE+MathPlayer private static final String OPERA = "Opera"; private static final String LYNX = "Lynx"; private static final String MSIE = "MSIE"; private static final String MSPIE = "MSPIE"; private static final String NETSCAPE = "Mozilla"; private static final String GECKO = "Gecko"; private static final String SAFARI = "Safari"; private static final String KONQUEROR = "Konqueror"; public static final String WIN = "Win"; public static final String MAC = "Mac"; public static final String UNIX = "Unix"; public static final String WIN_CE = "Windows CE"; public static final String UNKNOWN = "Unknown"; public static final String DEFAULT_SESSION_ATTRIBUTENAME = "org.hartmath.server.taglib.MathSniffer"; private String userAgent = null; private int browserId = 0; private String platform = null; private String accept = null; private String acceptLanguage = null; private String acceptCharset = null; private float version = 0; private boolean bot = false; private boolean aol = false; /** * Creates new BrowserDetection from Request(User-Agent). * * @param request */ public MathSniffer(HttpServletRequest request) { this.userAgent = request.getHeader("User-Agent"); this.accept = request.getHeader("Accept"); if (this.accept != null) this.accept = this.accept.toLowerCase(); this.acceptLanguage = request.getHeader("Accept-Language"); if (this.acceptLanguage != null) this.acceptLanguage = this.acceptLanguage.toLowerCase(); this.acceptCharset = request.getHeader("Accept-Charset"); if (this.acceptCharset != null) this.acceptCharset = this.acceptCharset.toLowerCase(); detect(); } /** * Creates new BrowserDetection from Request(User-Agent) and adds it to the Session as "attributeName". * * @param request * the HttpServletRequest * @param attributeName * the Name used for the session attribute */ public static void setBrowserDetection(HttpServletRequest request, String attributeName) { if (request.getSession(true).getAttribute(attributeName) == null) getBrowserDetection(request, attributeName); } /** * Creates new BrowserDetection a given User-Agent String * * @param userAgent * the userAgent * @deprecated please use BrowserDetection(HttpServletRequest request) instead */ public MathSniffer(String userAgent) { this.userAgent = userAgent; detect(); } /** * Creates new BrowserDetection from Request(User-Agent) and adds it to the Session as DEFAULT_SESSION_ATTRIBUTENAME. * * @param request * the HttpServletRequest */ public static MathSniffer getBrowserDetection(HttpServletRequest request) { return getBrowserDetection(request, DEFAULT_SESSION_ATTRIBUTENAME); } /** * Creates new BrowserDetection from Request(User-Agent) and adds it to the Session as "sessionAttributeName". * * @param request * the HttpServletRequest * @param sessionAttributeName * the Name of the Sessionattribute for the BrowserDetection object */ public static MathSniffer getBrowserDetection(HttpServletRequest request, String sessionAttributeName) { MathSniffer bd = (MathSniffer) request.getSession(true).getAttribute(sessionAttributeName); if (bd == null) { bd = new MathSniffer(request); request.setAttribute(sessionAttributeName, bd); } return bd; } /** * Standalone Testcode * * @param args */ public static void main(String[] args) { MathSniffer bd = new MathSniffer( //"Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) // Opera 7.01 [en] "); //"Lynx/2.8.3rel.1 libwww-FM/2.14"); //"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) // Gecko/20030312"); //"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) // Gecko/20020508 Netscape6/6.2.3"); //"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) "); //"Mozilla/2.0 (compatible; MSIE 3.01; Windows 3.1)"); //"Mozilla/4.75 [en] (Windows NT 5.0; U) "); //"Mozilla/2.0 (Macintosh; U; 68K)"); //"Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20010131 // Netscape6/6.0"); //"Mozilla/1.1 (compatible; MSPIE 1.1; Windows CE)"); //"Mozilla/4.0 (compatible; MSIE 5.5; Windows 98*)"); //"Mozilla/4.0 (compatible; MSIE 4.0b2; Windows 95)"); //"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/60 (like Gecko) Safari/60"); "Mozilla/3.04 (WinNT; U)"); // System.out.println(bd.getBrowser()); System.out.println(bd.getPlatform()); System.out.println(bd.getVersion()); } private void detect() { if (this.userAgent == null) { return; } this.browserId = OTHERSID; /////////////////////////////////////////////////// // Search-Engine /////////////////////////////////////////////////// String ua = this.userAgent.toLowerCase(); if (ua.indexOf("bot") != -1 || ua.indexOf("seek") != -1 || ua.indexOf("slurp") != -1 || ua.indexOf("spider") != -1 || ua.indexOf("crawl") != -1 || ua.indexOf("search") != -1 || ua.indexOf("teoma") != -1 || ua.indexOf("sleuth") != -1 || ua.indexOf("search") != -1 || ua.indexOf("find") != -1 || ua.indexOf("fireball") != -1 || ua.indexOf("scooter") != -1 || ua.indexOf("altavista") != -1 || ua.indexOf("netcraft") != -1 || ua.indexOf("gulliver") != -1 || ua.indexOf("ferret") != -1 || ua.indexOf("informant") != -1) { this.bot = true; return; } this.aol = this.userAgent.indexOf("AOL") != -1; /////////////////////////////////////////////////// // Browser und Version feststellen /////////////////////////////////////////////////// if (userAgent.indexOf(OPERA) != -1) { // this.browser = OPERA; this.browserId = CSSID; this.version = parseVersion(OPERA); } else if (userAgent.indexOf("MathPlayer") != -1) { this.browserId = MATHPLAYERID; this.version = parseVersion(MSIE); } else if (userAgent.indexOf(MSIE) != -1) { // this.browser = MSIE; // assumes MathPlayer plugin is installed this.browserId = MATHPLAYERID; this.version = parseVersion(MSIE); } else if (userAgent.indexOf(SAFARI) != -1) { // this.browser = SAFARI; this.browserId = CSSID; this.version = parseVersion(SAFARI); } else if (userAgent.indexOf(MSPIE) != -1) { // this.browser = MSPIE; this.browserId = MATHPLAYERID; this.version = parseVersion(MSPIE); } else if (userAgent.indexOf(KONQUEROR) != -1) { // this.browser = KONQUEROR; this.browserId = OTHERSID; this.version = parseVersion(KONQUEROR); } else if (userAgent.indexOf(GECKO) != -1) { // "Revision builds"/Netscape ab 6.0(???) // this.browser = MOZILLA; this.browserId = XMLID; this.version = parseVersion("rv:"); // "Milestone Builds"/Netscape 6.0, z.B. "m18" if (this.version == 5) this.version = (float) 0.5; } else if (userAgent.indexOf(NETSCAPE) != -1) { // this.browser = NETSCAPE; this.browserId = OTHERSID; this.version = parseVersion(NETSCAPE); } else if (userAgent.indexOf(LYNX) != -1) { // this.browser = LYNX; this.browserId = OTHERSID; this.version = parseVersion(LYNX); } else { // System.out.println("###\n### No Browsername found for:\n### " + this.userAgent + "\n###"); } /////////////////////////////////////////////////// // Platform feststellen /////////////////////////////////////////////////// if (userAgent.indexOf(WIN_CE) != -1) { this.platform = WIN_CE; } else if (userAgent.indexOf(WIN) != -1) { this.platform = WIN; } else if (userAgent.indexOf(MAC) != -1 || userAgent.indexOf("PPC") != -1) { this.platform = MAC; } else if ( userAgent.indexOf(UNIX) != -1 || userAgent.indexOf("Linux") != -1 || userAgent.indexOf("X11") != -1 || userAgent.indexOf("libwww") != -1 || userAgent.indexOf("SunOS") != -1) { this.platform = UNIX; } else { System.out.println("###\n### No Browser-Platform found for:\n### " + this.userAgent + "\n###"); } } private float parseVersion(String searchPattern) { try { String str = this.userAgent.substring(this.userAgent.indexOf(searchPattern) + searchPattern.length()); Pattern pattern = Pattern.compile("[0-9\\.]{2,}"); Matcher matcher = pattern.matcher(str); if (matcher.find()) { String versionString = matcher.group().trim(); if (versionString.indexOf(".") != -1) { String major = versionString.substring(0, versionString.indexOf(".")); Pattern dot = Pattern.compile("\\."); Matcher m = dot.matcher(versionString.substring(versionString.indexOf("."))); StringBuffer sb = new StringBuffer(); boolean result = m.find(); while (result) { m.appendReplacement(sb, ""); result = m.find(); } m.appendTail(sb); return Float.parseFloat(major + "." + sb.toString()); } else { return Float.parseFloat(versionString); } } } catch (Exception e) { e.printStackTrace(); } if (!this.bot) System.out.println("###\n### No Browser-Version found for:\n### " + this.userAgent + "\n###"); return 0; } /** * Tests if a browser explicitely accepts a given mime type. "*.*" is ignored. * * @param mimeType * a RFC mimetype such as "text/html", "application/xhtml+xml" or "image/gif" * @return true if the browser explicitely accepts a given mime type. * @since 1.1 */ public boolean acceptsMimeType(String mimeType) { if (mimeType == null) return false; mimeType = mimeType.toLowerCase(); return this.accept != null && this.accept.indexOf(mimeType) > -1; } /** * Tests if a browser explicitely accepts a given mime type and preferes to receive it over the second one. "*.*" is ignored. <b> * Note</b> that I assume that we do not pay attention to quantity statements such as "application/xhtml+xml;q=0.99" yet but * only the given order. Safari e.g. does not give a special order to its mimetypes, only quantity statement, so it does not work * with Safari! * * @param mimeType1 * a RFC mimetype such as "text/html", "application/xhtml+xml" or "image/gif" * @param mimeType2 * a RFC mimetype such as "text/html", "application/xhtml+xml" or "image/gif" * @return true if the browser explicitely accepts a given mime type. * @since 1.1 */ public int prefersMimeType(String mimeType1, String mimeType2) { if (this.accept == null || (!this.acceptsMimeType(mimeType1) && !this.acceptsMimeType(mimeType2))) return 0; else if ( this.acceptsMimeType(mimeType1) && !this.acceptsMimeType(mimeType2) || this.accept.indexOf(mimeType1) < this.accept.indexOf(mimeType2)) return 1; else return 2; } /** * Tests if a browser explicitely accepts a given language. * * @param language * a ISO language such as "en", "en-us" or "de" * @return true if the browser explicitely accepts a given language. * @since 1.1 */ public boolean acceptsLanguage(String language) { if (language == null) return false; language = language.toLowerCase(); return this.acceptLanguage != null && this.acceptLanguage.indexOf(language) > -1; } /** * Tests if a browser explicitely accepts a given character set. * * @param charset * a ISO language such as "utf-8", "ISO-8859-1" or "windows-1252" * @return true if the browser explicitely accepts a given language. * @since 1.1 */ public boolean acceptsCharset(String charset) { if (charset == null) return false; charset = charset.toLowerCase(); return this.acceptCharset != null && this.acceptCharset.indexOf(charset) > -1; } /** * @return String */ public String getPlatform() { return (platform != null) ? platform : UNKNOWN; } /** * @return String */ public String getUserAgent() { return (userAgent != null) ? userAgent : UNKNOWN; } /** * @return float the version number, e.g. 5.01 or 6.23 */ public float getVersion() { return version; } /** * @return boolean isMac */ public boolean isMac() { return (platform != null && platform.equals(MAC)); } /** * @return boolean isUnix */ public boolean isUnix() { return (platform != null && platform.equals(UNIX)); } /** * @return boolean isWin */ public boolean isWin() { return (platform != null && platform.equals(WIN)); } /** * @return boolean isWindowsCE */ public boolean isWindowsCE() { return (platform != null && platform.equals(WIN_CE)); } /** * @return isAol. * @since 1.1 */ public boolean isAol() { return aol; } /** * @return Returns the browserId. */ public int getBrowserId() { return browserId; } } Index: HeaderTag.java =================================================================== RCS file: /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/taglib/HeaderTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HeaderTag.java 20 Mar 2004 10:10:35 -0000 1.2 --- HeaderTag.java 20 Mar 2004 14:35:54 -0000 1.3 *************** *** 1,7 **** package org.hartmath.server.taglib; - import java.io.IOException; - - import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; --- 1,4 ---- *************** *** 23,56 **** // String bodyData = body.getString(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ! BrowserSniffer bd = BrowserSniffer.getBrowserDetection(request); ! // String appURL = Application.get().getConfiguration().getPath(); // ""; ! try { ! switch (bd.getBrowserId()) { ! case BrowserSniffer.MOZILLAID : ! pageContext.getResponse().setContentType("text/xml" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! request.getRequestDispatcher("gecko_header.jsp").include(request, pageContext.getResponse()); ! break; ! case BrowserSniffer.SAFARIID : ! case BrowserSniffer.OPERAID : ! pageContext.getResponse().setContentType( ! "application/xhtml+xml" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! request.getRequestDispatcher("opera_header.jsp").include(request, pageContext.getResponse()); ! break; ! case BrowserSniffer.NETSCAPEID : // old netscape newers are detected as Gecko ! case BrowserSniffer.MATHPLAYERID : ! case BrowserSniffer.MSIEID : ! pageContext.getResponse().setContentType("text/html" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! request.getRequestDispatcher("msie_header.jsp").include(request, pageContext.getResponse()); ! break; ! default : ! pageContext.getResponse().setContentType("text/html" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! request.getRequestDispatcher("msie_header.jsp").include(request, pageContext.getResponse()); ! break; ! } ! } catch (ServletException e) { ! e.printStackTrace(); ! } catch (IOException e) { ! e.printStackTrace(); } return SKIP_BODY; --- 20,50 ---- // String bodyData = body.getString(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ! MathSniffer bd = MathSniffer.getBrowserDetection(request); ! // String appURL = Application.get().getConfiguration().getPath(); // ""; ! // try { ! switch (bd.getBrowserId()) { ! case MathSniffer.XMLID : ! pageContext.getResponse().setContentType("text/xml" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! // request.getRequestDispatcher("gecko_header.jsp").include(request, pageContext.getResponse()); ! break; ! case MathSniffer.CSSID : ! pageContext.getResponse().setContentType( ! "application/xhtml+xml" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! // request.getRequestDispatcher("opera_header.jsp").include(request, pageContext.getResponse()); ! break; ! case MathSniffer.MATHPLAYERID : ! pageContext.getResponse().setContentType("text/html" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! // request.getRequestDispatcher("msie_header.jsp").include(request, pageContext.getResponse()); ! break; ! case MathSniffer.OTHERSID : ! pageContext.getResponse().setContentType("text/html" + "; charset=" + Application.get().getConfiguration().getEncoding()); ! // request.getRequestDispatcher("msie_header.jsp").include(request, pageContext.getResponse()); ! break; } + // } catch (ServletException e) { + // e.printStackTrace(); + // } catch (IOException e) { + // e.printStackTrace(); + // } return SKIP_BODY; |