How to detect Browser using JSP ?

Hi friends,
I wanna to put some code to detect browser and
Other than IE6+ i have to block other browser to display login.
How do i check that ? Using JSP.
e.g.
If i open IE6+ login page should be displayed. Else on other browsers
it will check brower and deny to display login page.
How Do i check it ? please Help me.

this code works for me in IE,Safari and firefox but i could not check in netscape as i dont have.
String userAgent = request.getHeader("User-Agent");
      System.out.println("UserAgent:"+userAgent);
      userAgent=userAgent.toLowerCase(); //convert to lowercase and then check
      if(userAgent.indexOf("netscape6") != -1)
     System.out.println("Netscape");
      else if(userAgent.indexOf("msie") != -1)
          System.out.println("IE");
     else if(userAgent.indexOf("firefox") != -1)
     System.out.println("Firefox");
     else if(userAgent.indexOf("safari") != -1)
     System.out.println("Safari");
     else
          System.out.println("Else");
    

Similar Messages

  • How to upload the image and diplay the image in the browser using jsp

    How to upload the image and diplay the image in the browser using jsp
    thanks
    shan

    i'll suggest looking for sample code or tutorial with a relevant query in google, which as far more time than us to answer this type of reccurent question

  • How to open a pdf file in a web browser using jsp

    Hi,
    I have a problem opening pdf file in browser using jsp.the following is my code.Can anyone help me.Thanks
    response.setContentType("application/pdf");
    String filename="C:\\FictPos\\mypdf.pdf";
    File file = new File(filename);
    FileInputStream in = new FileInputStream(file);
    OutputStream out1=response.getOutputStream();
    byte[] buf = new byte[4096];
    int count = 0;
    while ((count = in.read(buf)) >= 0)
    out1.write(buf, 0, count);
    in.close();
    out1.close();
    }

    Don't know the problem specifically, but here are some suggestions to investigate:
    Does it show anything in the page when you view source on it?
    I would recommend using a servlet rather than a JSP page for this, if only for the fact the JSPs can insert carriage returns into places where you might not want them to. This might screw up the PDF file format?
    Try setting the a link to the jsp, right-click and "save target as..." just to see if it gets any response at all - ie bypass the browser display.
    Good luck,
    evnafets

  • How to Detect browser crash

    hi i want to know how to detect browser crash or the way to go about it , i can use any language to any api's plz specify me some solution .It would be really healpfull

    paul_123 wrote: hi i want to know how to detect browser crash ..
    Like the other person that replied, I do not quite understand why it is of interest that the end user's browser crashes. If, like they suspect, it is to do with your applet, I think the best solution is to launch the applet using webstart and forget the browser. If the end user launches a webstart based applet from the browser and the browser crashes, the applet will keep working just fine.
    Is your applet publicly available? If so, what is the URL where we can see it?

  • Can I get information regarding the client browser using JSP

    can I get information regarding the client browser using JSP. like.. name, screen resolutions, font type, screen width and height of the browser etc.,
    if possible then please give me the samples..
    thanks,

    can I get information regarding the client browser using JSP. like.. name, screen resolutions, font type, screen width and height of the browser etc.,
    if possible then please give me the samples..
    thanks,

  • How to run exception using JSP?

    How to run exception using JSP?

    Why would you need the <%%> between the if else blocks? Even if you attempt to write some data within the blocks in java, you will still get an error. For example, this is illegal:
    if(done)
        System.out.println(true);
    System.out.println("Hello World");
    else
        System.out.println(false);
    }The compiler is expecting the 'else' to be directly after the body of the if. If it encounters anything else, it will complain. So you cannot do this in jsp either, regardless if it's a different technology, it's the same compiler.

  • How to detect browser close event in flex ?

    How to detect browser close event in flex ?

    This link may help:
    http://cookbooks.adobe.com/post_Close_event_of_browser_or_browser_tab-18211.html
    Best,

  • Uploading the file to server from the browser using JSP

    I have facing difficulty while uploading the file from the browser using user interface to the server or to the database. As previousy i was working in coldfusion, i find it very easy there with cffile command, but i am confused how to do that in JSP
    please reply soon, as i am stuck in my project because of that
    Sarosh

    Check out http://www.jspsmart.com , They have a nice free upload api that can be used w/ JSPs or Servlets. I hear O'Reilly has a nice one too. May as well use someone elses if they've done it already.

  • Diasble Address/Menu Bars of a Browser using JSP

    HI,
    Is there a way to disable or hide Menu Bar/Address Bar of a Browser i.e. Internet Explorer and Netscape using JSP. Don't want to use Javascript as what if JavaScript is disabled in the browser. Can someone please help me how to hide the Browser Bars using JSP.
    Thanks

    Can't be done. JSP is SERVER-SIDE execution, not CLIENT-SIDE.
    JavaScript is your only bet here. If it is VITALLY important to you, have your main window launch another window using JavaScript. If javaScript is disabled, post a little warning that JavaScript must be enabled to use this site.

  • Diaplay  Word file stored in blob into a browser using JSP

    Dear All
    I have files stored in oracle table in a blob field.I store the files using forms 10g and webutil. I can upload the files and display them successfully in forms, however when i use JSP to retrieve the files and display them in Internet Explorer, I'm able to display the pdf files, bmp , jpg and video but I'm getting junk characters when I try displaying (word , excel , access or powerpoint files which might contain arabic Characters )
    the code I use to display the files is as follows :
    <%
    try
    Connection conn = null;
    String username=session.getAttribute("username").toString().toUpperCase();
    String password=session.getAttribute("password").toString().toUpperCase();
    String ip = "*****************";
    String sid = "***************";
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@"+ip+":1521:"+sid,username,password);
    String par = request.getParameter("LETTER");
    String par1 = request.getParameter("SERIAL");
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from TableName where PK1 like '"+par+"'"+" and PK2 like '"+par1+"'" );
    if (rs.next())
    Blob pic = null;
    byte[] blobBytesArray = null;
    OutputStream stream = response.getOutputStream();
    pic = rs.getBlob("BLOBFIELD");
    int len = new Integer( new Long( pic.length()).toString() ).intValue();
    blobBytesArray = pic.getBytes(1,len);
    if (blobBytesArray != null)
    if (blobBytesArray.length > 0 )
    stream.write(blobBytesArray) ;
    catch(Exception e)
    System.out.println("Exception: " + e.getMessage() + "<BR>");
    %>
    can you please guide me of how to display other file types.
    Best Regards.

    Hello,
    Ideally when you store the document put the content-type in a column and set the content type in your JSP. This will indicate to the browser what is the type of file and you should not have any issue with any type.
    Regards
    Tugdual Grall

  • Detect browser using velocity

    Can any one tell me how the codes are written in velocity to detect browser.

    AmitChalwade123456 wrote:
    rrp wrote:
    Can any one tell me how the codes are written in velocity to detect browser.what's this velocity ?? share u r knowledge with usVelocity is a templating engine. [ http://velocity.apache.org/ ].
    I think I would put the browser discovery code (if I really had to use it) in controller. (Or JavaScript).

  • Display binary data from DB in browser using JSP

    Hello everyone:
    I uploaded some files from browser and stored the files in bytes in the database, but later on I could not display the files in browser without saving them to a local storage first. Is there any way I can send the bytes to the browser in the right format using JSP?
    I tried the following:
    response.setContentType(..)
    response.getOutputStream().write(bytes);
    I can see that the browser can get the right contentType, but with a bunch of weird symbols in the browser. Please help.
    Thank you very much for your time.
    Heather

    I actually had to do this a few months ago. There are ways to perform this kind display using various distributed object (i.e., using MS Word OLE objects to "interpret" the byte for you, etc.). But this soon got extremely difficult to manage (and I actually had to use Perl/CGI for the majority of it).
    The solution I went with was to implement a "cache" directory on the web server. Basically, the JSP/Servlet can simply check the cache and if file not there, create it from the database. Then send a redirect back to the browser to this newly-created file. The browser will then appropriately open the document. I tested this with both Netscape and IE browsers and common MIME types such as text files, MS Office docs, zip files, PDFs, RTFs.
    Not ideal, but unfortunately the best I came up with.

  • How To Detect Color using my application

    Hi Friends,
    Iam sachin, working as a iphone mobile application developer.K coming to my question is it possible to
    detect colors using our application if yes Kindly guide me how to proceed .
    Thanks in advance ,

    you need to ask this in the developers forum - this is a formum mostly for end users not developers

  • How to make it using JSP??

    Hi,
    Go to http://www.mycgiserver.com/~sterowanie/index.jsp
    Now write user: qq, password: qq
    Write something in the text field and push "Szukaj" (this means "search")
    As you see it connects to google and display results.
    The problem is that this was done using <iframe> tag. I would like to do this using JSP (without using frames).
    Anybody knows how to do that ?
    thanks in advance

    When your SessionServlet finds the queryBut my SessionServlet is working as a login module. It don't do anything with searching. Searching is realised by simple html file. Here is source of this file:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Zalogowany</title>
    <style type="text/css">
    body {
         background-color: #FFF;
         color: #000;
    form {margin: 0;}
    td.search {
         background-color: #00f;
         color: #FFF;
         border: 1px solid #000;
         padding: 1em;
         text-align: right;
    td.leftbar {
         width: 23%;
         background-color: #00f;
         color: #FFF;
    td.content {
         width: 77%;
    </style>
    </head>
    <body>
    <table border="1" width="83%">
    <tr>
    <td colspan="2" class="search">
         <form ACTION="http://www.google.pl/search?" METHOD="get" target="myFrame">
         <input TYPE="TEXT" NAME="q">   <input TYPE="SUBMIT" NAME="Szukaj" VALUE="Szukaj">
         </form>
    </tr>
    <tr>
    <td class="leftbar"> </td>
    <td class="content">
    <!--          <iframe src="/spis.jsp" name="myFrame" width="100%" height="467" scrolling="auto" frameborder="0"></iframe>-->
         <%@ include file="/spis.jsp"%>
         </td>
    </tr>
    </table>
    </body>
    </html>

  • Can any one answer me how to import and use jsp libraries into uix file and

    Hi guys
    can any one help me how to import jsp libraries in to my uix file with jdev 10g production adn how to use them..if any one got any sample for this i appreciate if u cans end me that
    thanks
    Venkat

    you cannot use jsp tags inside uix xml pages.
    you can, however, use uix jsp tags inside jsp pages.

Maybe you are looking for