Results 1 to 3 of 3
  1. #1
    BordomSUCKS is offline Member
    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

    Exclamation Why does .jsp page show only code when the website is hit.

    So I am currently running tomcat 6.0 on port 8080. All of the out of the box application websites are in java code and are functioning as expected. We are looking at doing a CAC authentication piece and I have finished the settings in tomcat for setting the keystore and doing the public trust. But I am trying to run a .jsp with just this code in it to validate I can pull the x509 certificate and when I hit the site all it does is show code. I am completly new to JAVA but a fast learner and looking to understand why this code I found would not do anything but show as text when hitting the link. Windows Server 64 bit running tomcat in 32 bit mode. I have a login.jsp for the application that is running and working. But the custom jsp I place in the folder with the login and it just shows the code. Below is the code any help would be greatly appreciated.

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.security.cert.X509Certificate;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class X509Snoop extends HttpServlet {

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
    IOException {
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();

    X509Certificate[] certs = (X509Certificate[]) req
    .getAttribute("javax.servlet.request.X509Certifica te");
    if (certs != null) {
    for (int i = 0; i < certs.length; i++) {
    out.println("Client Certificate [" + i + "] = " + certs[i].toString());
    }
    } else {
    if ("https".equals(req.getScheme())) {
    out.println("This was an HTTPS request, " + "but no client certificate is available");
    } else {
    out.println("This was not an HTTPS request, " + "so no client certificate is available");
    }
    }
    }
    }

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    618
    Rep Power
    4

    Default

    Hi Recently I had the same task. It took many hours. Look at this Tomcat web application with SSL client certificates Virgo's Naive Stories. It is wonderful article about configurations tomcat for CA.
    if you have question you will be able to ask here.
    Regard.
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    BordomSUCKS is offline Member
    Join Date
    Jun 2011
    Posts
    7
    Rep Power
    0

Similar Threads

  1. Download then show page from jsp
    By aflores in forum New To Java
    Replies: 4
    Last Post: 09-10-2010, 09:26 AM
  2. Trying to login to a website then grab another page
    By DaveTheAve in forum New To Java
    Replies: 6
    Last Post: 04-14-2010, 09:44 PM
  3. Replies: 1
    Last Post: 08-29-2008, 01:54 PM
  4. show a value in javascipt in the jsp page
    By hussainzim in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-20-2008, 09:38 AM
  5. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 06:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •