Reputation: 51
I am using intellij idea 14 to create a web app using servlet and jsp but whenever i try to pass value from jsp there is error as
HTTP Status 404 - /Books/BookSaleAuctionServlet
type Status report
message /Books/BookSaleAuctionServlet
description The requested resource is not available.
Apache Tomcat/7.0.30
Myfiles are : 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 is servlet as BookSaleAuctionServlet
inside Books
package and it 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 with 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 help
Upvotes: 0
Views: 105
Reputation: 8354
change
action="Books/BookSaleAuctionServlet"
to action="/bookSaleAuction"
Upvotes: 3