请求的资源不可用html,“HTTP状态404请求的资源不可用”

我是servlet编程的新手。我检查了有关Http 404错误的其他各种链接,但没有任何帮助。所以我在这里发布我的代码。“HTTP状态404请求的资源不可用”

我在WebContent/文件夹form1.html,form2.html,form3.html了3种HTML形式,所有这些形式都相同的URL模式,因为在相同的HTTP会话中访问三种不同的形式。

form1.html

Adhar Registration Form

FORM 1

NAME:
F_NAME:
M_NAME:

form2.html

Adhar Registration Form

FORM 2

CONTACT:
EMAIL:
ADDRESS:
Adhar Registration Form

FORM 3

QUALIFICATION:
PAN NO:

的web.xml

Adhar

form1.html

login

container.RegistrationServlet

login

/reg

RegistrationServlet.java

package container;

import java.io.IOException;

import java.io.PrintWriter;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

/**

* Servlet implementation class RegistrationServlet

*/

@WebServlet("/reg")

public class RegistrationServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

public static final String URL = "jdbc:mysql://localhost/db";

public static final String USER = "root";

public static final String PASSWORD = "12345";

public static final String DRIVER_CLASS = "com.mysql.jdbc.Driver";

/**

* @see HttpServlet#HttpServlet()

*/

public RegistrationServlet() {

super();

// TODO Auto-generated constructor stub

}

/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)

*/

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

PrintWriter out = response.getWriter();

HttpSession hs = request.getSession();

String fno = request.getParameter("fno");

if(fno.equals("1")){

String name = request.getParameter("name");

String f_name = request.getParameter("f_name");

String m_name = request.getParameter("m_name");

hs.setAttribute("name", name);

hs.setAttribute("f_name", f_name);

hs.setAttribute("m_name", m_name);

response.sendRedirect("./Form2.html");

}

if(fno.equals("2")){

String contact = request.getParameter("contact");

String email = request.getParameter("email");

String address = request.getParameter("address");

hs.setAttribute("contact", contact);

hs.setAttribute("email", email);

hs.setAttribute("address", address);

response.sendRedirect("./Form3.html");

}

if(fno.equals("3")){

String qual = request.getParameter("qual");

String pan = request.getParameter("pan");

String name = (String)hs.getAttribute("name");

String f_name = (String)hs.getAttribute("f_name");

String m_name = (String)hs.getAttribute("m_name");

String contact = (String)hs.getAttribute("contact");

String email = (String)hs.getAttribute("email");

String address = (String)hs.getAttribute("address");

try {

Class.forName(DRIVER_CLASS);

System.out.println("Loaded the driver");

Connection con = DriverManager.getConnection(URL,USER,PASSWORD);

PreparedStatement ps = con.prepareStatement("INSERT into adharReg values(?,?,?,?,?,?,?,?)");

ps.setString(1, name);

ps.setString(2, f_name);

ps.setString(3, m_name);

ps.setString(4, contact);

ps.setString(5, email);

ps.setString(6, address);

ps.setString(7, qual);

ps.setString(8, pan);

int i = ps.executeUpdate();

if(i!=0){

out.println("

REGISTRATION SUCCESS

");

}

else{

out.println("

REGISTRATION FAILED

");

}

} catch (Exception e) {

// TODO: handle exception

out.println("

REGISTRATION FAILED" + e.getMessage() + "

");

}

}

}

}

我使用Tomcat服务器8.0。我检查了这个Link和我的tomcat服务器具有完全相同的设置。对于任何可能出现的错误,都遵循this link,但是,我不知道为什么我收到Http 404错误的确切原因。帮我解释为什么我得到这个错误。

谢谢。

2017-07-16

karthi13

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值