java - Passing value from jsp to servlet but servlet is not available -
i using intellij idea 14 create web app using servlet , jsp whenever try pass value jsp there error
http status 404 - /books/booksaleauctionservlet type status report message /books/booksaleauctionservlet description requested resource not available. apache tomcat/7.0.30
myfiles : index.jsp
<form method= "get" action="books/booksaleauctionservlet"> username : <input type="text" name="name" id="name"> address : <input type="text" name="address" id="address"> contact : <input type="tel" name="contactno" id="contactno"> email : <input type="email" name="email" id="email"> password : <input type="password" name="pass" id="pass"> <input type="submit" name="save">
and there servlet booksaleauctionservlet
inside books
package , contains
protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string name = request.getparameter("name"); string address = request.getparameter("address"); string contact = request.getparameter("contact"); string email = request.getparameter("email"); string pass = request.getparameter("pass"); system.out.println("check 1"); try { class.forname("com.mysql.jdbc.driver"); } catch(classnotfoundexception e) { system.out.println("class not found "+ e); } system.out.println("jdbc class found"); try { connection con = drivermanager.getconnection("jdbc:mysql://localhost/logins", "root", ""); statement stmt = con.createstatement(); resultset rs = stmt.executequery ("create table members (user_id int(11) not null auto_increment,\n" + " username varchar(45) not null,\n" + " password varchar(45) not null,\n" + " contact varchar(45) not null,\n" + " email varchar(45) not null,\n" + " primary key (user_id)\n" + "); "); } catch(sqlexception e){ system.out.println("sql exception occured" + e); } system.out.print("done databases"); }
and web.xml
<servlet> <servlet-name>booksaleauctionservlet</servlet-name> <servlet-class>books.booksaleauctionservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>booksaleauctionservlet</servlet-name> <url-pattern>/booksaleauction</url-pattern> </servlet-mapping>
please
change action="books/booksaleauctionservlet"
action="/booksaleauction"
Comments
Post a Comment