Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012
    Rep Power

    Default Input Validation Error

    Hi there,

    I was trying an input validation example taken from the OWASP ESAPI and I am getting the following error:

    Error: Cannot make a static reference to the non-static method getValidInput(String, String, String, int, boolean) from the type Validator


    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    	<form method="post" action="inputvalidation">
    		Enter zip:<input type="text" name="zip" />


    Java Code:
    package com.example.web;
    import org.owasp.esapi.*;
    import org.owasp.esapi.errors.ValidationException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class InputValidation extends HttpServlet {
    private static final long serialVersionUID = 1L;
        public InputValidation() {
            // TODO Auto-generated constructor stub
    	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		PrintWriter out=response.getWriter();
    			 String zipCode=Validator.getValidInput("ChangeAddressPage_ZipCodeField",
                             request.getParameter( "zip" ), 
                              "zipCodePattern", 10, false); //Error on this line 
    		catch(ValidationException e)
    			response.sendError( response.SC_BAD_REQUEST, e.getMessage() );
    Any suggestions?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Input Validation Error

    Cannot make a static reference to the non-static method
    Create an instance or get a reference to the class and use that reference to call the method.
    Or make the method static

    This syntax: CLASSNAME.methodName is a static refererence.

Similar Threads

  1. Input validation help
    By AdamG in forum New To Java
    Replies: 3
    Last Post: 10-17-2011, 10:29 PM
  2. Input Validation Help
    By Spyderpig in forum New To Java
    Replies: 3
    Last Post: 02-18-2011, 12:58 PM
  3. JTable input validation
    By Manfizy in forum New To Java
    Replies: 10
    Last Post: 06-10-2009, 10:04 AM
  4. Input Validation
    By kickflipper1087 in forum New To Java
    Replies: 5
    Last Post: 11-03-2008, 06:47 AM

Posting Permissions

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