tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: servlet question
Date Mon, 16 Aug 2004 03:57:40 GMT
Well, you could try adding in your exception handling:
    } catch(Exception e) {
       log("Problem",e);
       // For pre-production debugging only
       throw new ServletException("Problem",e);
    }

The way you servlet is at the moment, if you do get an exception, then all
you will see is a blank page with nothing in the logs.

"Schalk Neethling" <schalk@volume4.co.za> wrote in message
news:411E7681.50106@volume4.co.za...
> Attached is my servlet and complete web.xml
>
> David Short wrote:
>
> >I don't think the servlet is the issue, since it's not even getting
> >executed.  Is your context path set up correctly in your servlet.xml or
> >tomcat\conf\catalina\localhost\context.xml file (tomcat 5).
> >
> >Which version of tomcat are you running and on what os?
> >
> >-----Original Message-----
> >From: Schalk Neethling [mailto:schalk@volume4.co.za]
> >Sent: Saturday, August 14, 2004 1:22 PM
> >To: Tomcat Users List
> >Subject: Re: servlet question
> >
> >
> >Attached is the servlet, can you see any problems here? It compiles fine.
> >
> >David Short wrote:
> >
> >
> >
> >>Are you running this through apache redirected to tomcat or straight
from
> >>tomcat?
> >>
> >>Try loading the servlet at tomcat startup to see if the servlet is
> >>recognized.
> >>
> >>i.e.     <load-on-startup>1</load-on-startup>
> >>
> >>last in the <servlet></servlet> tag set.
> >>
> >>I had the same issue and discovered that my pattern in apache wasn't
right.
> >>However, if you're not using apache, I don't know what to say.  The
syntax
> >>looks correct.
> >>
> >>-----Original Message-----
> >>From: Schalk Neethling [mailto:schalk@volume4.co.za]
> >>Sent: Saturday, August 14, 2004 1:05 PM
> >>To: Tomcat Users List
> >>Subject: re: servlet question
> >>
> >>
> >>Hey all!
> >>
> >>I have a servlet called login. I have it mapped in my web.xml as
follows:
> >>
> >><servlet>
> >>   <servlet-name>login</servlet-name>
> >>   <servlet-class>org.volume4.authentication.login</servlet-class>
> >></servlet>
> >><servlet-mapping>
> >>   <servlet-name>login</servlet-name>
> >>   <url-pattern>*.login</url-pattern>
> >></servlet-mapping>
> >>
> >>My WEB-INF structure is as follows
> >>
> >>WEB-INF/classes/org/volume4/authentication/login.class
> >>
> >>Does anyone have an idea as to why when I call login as process.login
> >>
> >>
> >>from a form it is not run? I have placed some System.out.println(); in
> >
> >
> >>there but, it seems that the servlet is not called at all. I basically
> >>just get a blank screen. When I look at the tomcat logs no errors are
> >>recorded here either.
> >>
> >>--
> >>Kind Regards
> >>Schalk Neethling
> >>Web Developer.Designer.Programmer.President
> >>Volume4.Development.Multimedia.Branding
> >>emotionalize.conceptualize.visualize.realize
> >>Tel: +27125468436
> >>Fax: +27125468436
> >>email:schalk@volume4.co.za
> >>web: www.volume4.co.za
> >>
> >>This message contains information that is considered to be sensitive or
> >>confidential and may not be forwarded or disclosed to any other party
> >>without the permission of the sender. If you received this message in
> >>
> >>
> >error,
> >
> >
> >>please notify me immediately so that I can correct and delete the
original
> >>email. Thank you.
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >>
> >
> >--
> >Kind Regards
> >Schalk Neethling
> >Web Developer.Designer.Programmer.President
> >Volume4.Development.Multimedia.Branding
> >emotionalize.conceptualize.visualize.realize
> >Tel: +27125468436
> >Fax: +27125468436
> >email:schalk@volume4.co.za
> >web: www.volume4.co.za
> >
> >This message contains information that is considered to be sensitive or
> >confidential and may not be forwarded or disclosed to any other party
> >without the permission of the sender. If you received this message in
error,
> >please notify me immediately so that I can correct and delete the
original
> >email. Thank you.
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >
>
> -- 
> Kind Regards
> Schalk Neethling
> Web Developer.Designer.Programmer.President
> Volume4.Development.Multimedia.Branding
> emotionalize.conceptualize.visualize.realize
> Tel: +27125468436
> Fax: +27125468436
> email:schalk@volume4.co.za
> web: www.volume4.co.za
>
> This message contains information that is considered to be sensitive or
confidential and may not be forwarded or disclosed to any other party
without the permission of the sender. If you received this message in error,
please notify me immediately so that I can correct and delete the original
email. Thank you.
>
>


----------------------------------------------------------------------------
----


> /*
>  * login.java
>  *
>  * Created on January 18, 2004, 9:47 PM
>  */
>
> package org.volume4.authentication;
>
> import java.io.*;
> import java.util.*;
> import java.net.*;
> import java.sql.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> /**
>  *
>  * @author  Design_DEMON
>  * @version
>  */
> public class login extends HttpServlet {
>     public String DRIVER, URL, USER, PASS, username, userid, password,
user_role;
>     /** Initializes the servlet.
>      */
>     public void init() throws ServletException {
>     ServletContext context = getServletContext();
>     DRIVER = context.getInitParameter("driver");
>     URL = context.getInitParameter("dburl");
>     USER = context.getInitParameter("dbuser");
>     PASS = context.getInitParameter("dbpass");
>     }
>
>
>     /** Processes requests for both HTTP <code>GET</code> and
<code>POST</code> methods.
>      * @param request servlet request
>      * @param response servlet response
>      */
>     protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
>     throws ServletException, java.io.IOException {
>         response.setContentType("text/html");
>         PrintWriter out = response.getWriter();
>         Connection con = null;
>
>         try {
>           username = request.getParameter("username");
>           userid = request.getParameter("userid");
>           password = request.getParameter("password");
>
>           System.out.println(username);
>           System.out.println(userid);
>           System.out.println(password);
>
>           Class.forName(DRIVER);
>           con = DriverManager.getConnection(URL,USER,PASS);
>           PreparedStatement stmt = con.prepareStatement(
>           "SELECT * from mi_users WHERE username= '" + username + "' " +
>           "AND userid = '" + userid + "' " +
>           "AND password= '" + password + "'");
>
>           ResultSet rs = stmt.executeQuery();
>
>           boolean foundUser = false;
>
>           while(rs.next()) {
>               foundUser = true;
>
>               HttpSession session = request.getSession(true);
>               session.setMaxInactiveInterval(1800);
>               session.setAttribute("username", username);
>               session.setAttribute("userid", userid);
>               session.setAttribute("password", password);
>
>               //Get user information from ResultSet object
>                 String userid = rs.getString(1);
>                 username = rs.getString(2);
>                 String user_role = rs.getString(4);
>                 String firstName = rs.getString(6);
>                 String lastName = rs.getString(7);
>                 String phone = rs.getString(13);
>                 String email = rs.getString(15);
>
>                 // Place values obtained from ResultSet into
>                 // the current session.
>                 session.setAttribute("userid", userid);
>                 session.setAttribute("firstName", firstName);
>                 session.setAttribute("lastName", lastName);
>                 session.setAttribute("phone", phone);
>                 session.setAttribute("email", email);
>
>                 if(user_role == "user") {
>                     response.sendRedirect("user/index.jsp");
>                 } else {
>                     response.sendRedirect("admin/index.jsp");
>                 }
>             }
>           if (foundUser == false)
>               response.sendRedirect("login_failed.jsp");
>
>         } catch(Exception e) {
>         }
>     }
>
>     /** Handles the HTTP <code>GET</code> method.
>      * @param request servlet request
>      * @param response servlet response
>      */
>     protected void doGet(HttpServletRequest request, HttpServletResponse
response)
>     throws ServletException, java.io.IOException {
>         processRequest(request, response);
>     }
>
>     /** Handles the HTTP <code>POST</code> method.
>      * @param request servlet request
>      * @param response servlet response
>      */
>     protected void doPost(HttpServletRequest request, HttpServletResponse
response)
>     throws ServletException, java.io.IOException {
>         processRequest(request, response);
>     }
> }
>


----------------------------------------------------------------------------
----


> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
> <!--
>                 Sun Public License Notice
>
> The contents of this file are subject to the Sun Public License
> Version 1.0 (the "License"). You may not use this file except in
> compliance with the License. A copy of the License is available at
> http://www.sun.com/
>
> The Original Code is NetBeans. The Initial Developer of the Original
> Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
> Microsystems, Inc. All Rights Reserved.
> -->
> <web-app>
>   <display-name>Volume4 and ManageIT Web Services and
Applications</display-name>
>   <description>This is the web.xml for all Web Applications and Services
running from www.myjcms.com</description>
>   <context-param>
>     <param-name>driver</param-name>
>     <param-value>com.mysql.jdbc.Driver</param-value>
>   </context-param>
>   <context-param>
>     <param-name>url</param-name>
>     <param-value>jdbc:mysql://localhost/meccafemme</param-value>
>   </context-param>
>   <context-param>
>     <param-name>user</param-name>
>     <param-value>meccafemme</param-value>
>   </context-param>
>   <context-param>
>     <param-name>pass</param-name>
>     <param-value>o3r72esa</param-value>
>   </context-param>
>   <servlet>
>     <servlet-name>login</servlet-name>
>     <servlet-class>org.volume4.authentication.login</servlet-class>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>login</servlet-name>
>     <url-pattern>*.login</url-pattern>
>   </servlet-mapping>
>   <session-config>
>     <session-timeout>30</session-timeout>
>   </session-config>
>   <welcome-file-list>
>     <welcome-file>index.jsp</welcome-file>
>     <welcome-file>index.html</welcome-file>
>   </welcome-file-list>
> </web-app>
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message