tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Wingfield <jon.wingfi...@mkodo.com>
Subject Re: inserting data (A weird problem)
Date Wed, 14 Dec 2005 12:00:42 GMT
Looking at the attached jsp I can see it does
cto.setapellido(request.getParameter("apellido"));
which is correct for the supplied bean code.

As the NoSuchMethodError is occuring at runtime rather than at jsp 
compile time I would say you have probably changed the bean code since 
the jsp was last compiled.
Have a look in the tomcat logs for jsp compilation errors.
Make sure the compiled class of the bean is correct version of the code.
And, if worst comes to worst, try deleting tomcat's work directory to 
clear out any stale jsp class files.

Jon Wingfield wrote:
> This is how I read the error: There is no method with the signature
> 
> void setapellido(String[] values)
> 
> which (given your code sample) there isn't.
> 
> Is the insertar.jsp doing something like
> contacto.setapellido(request.getParameterValues("name"));
> 
> instead of
> 
> contacto.setapellido(request.getParameter("name"));
> 
> HTH,
> 
> Jon
> 
> Claudio Veas wrote:
> 
>>
>> Hello, Im trying to insert data in my mysql server with a JSP and a 
>> Bean with an example I found in the internet, Im very new to all this 
>> but this error I get its really strange.
>> I created a table contacto (contact) in the mysql server,
>> create table contacto (numero int,
>>                                        nombre varchar (20),
>>                                        apellido varchar(20),
>>                                        Telefono int,
>>                                         Email varchar(50)
>> )
>> I made the bean acording to the example and I made a form so I can 
>> Input the data and the job of the bean would be to save this info in 
>> the database. But the problem is that I got an Error
>>  
>>  
>>
>> javax.servlet.ServletException: 
>> DB.contacto.setapellido(Ljava/lang/String;)V
>>     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)

>>
>>     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)

>>
>>     org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:85)

>>
>>     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)

>>
>>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) 
>>
>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>
>> *causa raĆ­z*
>>
>> java.lang.NoSuchMethodError: DB.contacto.setapellido(Ljava/lang/String;)V
>>     org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:59)

>>
>>     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)

>>
>>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) 
>>
>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>
>> so I decided to take out all the logic of the "apellido" field in the
>> database and I took it out of the form and from the JSP file and guess 
>> what it
>> Worked so I put all the "apellido" stuffs back with extra care of no 
>> making any mistakes
>> this time, Idouble checked it with the other fields because hey they 
>> work but guess what
>>
>> the error showed up again and I dont really know what the problem is, 
>> all I know its something related
>>
>> to the get statement.
>> Hope You can Help me
>>
>> Thanks on Advance
>>
>> Claudio Veas
>>
>> Please Excuse my english
>>        
>>
>> Add FUN to your email - CLICK HERE! 
>> <http://www.incredimail.com/index.asp?id=96769>
>>
>>
>> ------------------------------------------------------------------------
>>
>> package DB;
>>
>> import java.sql.*;
>> import java.io.*;
>>
>> public class contacto {
>>
>>    private String dbURL = 
>> "jdbc:mysql://localhost:3306/test?user=jonas&password=jonas";
>>    private String dbDriver = "com.mysql.jdbc.Driver";
>>    private Connection dbCon;
>>       String Numero =null;
>>    String Nombre = null;
>>     String apellido =null;
>>    String Telefono = null;
>>    String Email = null;
>>  
>>    public contacto() {
>>       super();
>>    }
>>
>>    public String getNumero() {
>>        return this.Numero;
>>    }
>>    public String getNombre() {
>>        return this.Nombre;
>>    }
>>    public String getapellido(){
>>        return this.apellido;
>>        }
>>    public String getTelefono() {
>>        return this.Telefono;
>>    }
>> public String getEmail() {
>>        return this.Email;
>>    }
>>             
>>    public void setNumero(String Numero) {
>>        this.Numero = Numero;
>>    }
>>
>>    public void setNombre(String Nombre) {
>>        this.Nombre = Nombre;
>>
>>    }
>>
>> public void setapellido(String apellido) {
>>        this.apellido = apellido;
>>
>>    }
>>
>>     public void setTelefono(String Telefono) {
>>        this.Telefono = Telefono;
>>    }
>>     public void setEmail(String Email) {
>>        this.Email = Email;
>>    }
>>
>>    public void doInsert() throws ClassNotFoundException, SQLException {
>>       Class.forName(dbDriver);
>>       dbCon = DriverManager.getConnection(dbURL);
>>       Statement s = dbCon.createStatement();
>>       String sql = "INSERT INTO contactos values (" + this.Numero;
>>       sql = sql + ", '" + this.Nombre;
>>       sql = sql + "', " + this.Telefono + ", '" + this.Email;
>>       sql = sql + "')";
>>       int insertResult = s.executeUpdate(sql);
>>       dbCon.close();
>>    }
>>     }
>>
>>
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



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


Mime
View raw message