Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSP与javaservlet_Java_Jsp_Servlets - Fatal编程技术网

JSP与javaservlet

JSP与javaservlet,java,jsp,servlets,Java,Jsp,Servlets,我有一些密码。它可以在JSp中工作,但不能在Javaservlet中工作。我正在这里粘贴代码。你能在servlet文件中声明错误吗 JSP: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> &l

我有一些密码。它可以在JSp中工作,但不能在Javaservlet中工作。我正在这里粘贴代码。你能在servlet文件中声明错误吗

JSP:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String rollno=null;
String category=null;
rollno=request.getParameter("rollno");
category=request.getParameter("category");
out.println(rollno+"\n"+category+"\n");
%>
</body>
</html>

使用doGet方法而不是doPost

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

使用doGet方法而不是doPost

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

它在JSp中工作而在JavaServlet中不工作意味着什么?我能看到的唯一区别是HTML头和其他标记(servlet不生成这些标记)。当然,JSP不仅响应POST.scriplets,而且对将来的问题也不好,告诉我们错误,而不是忽略它。错误包含问题的答案。您可能会得到一个“HTTP 405 method not allowed”错误,它本身就是完整的答案(只需要翻译成外行的术语)。它在JSp中工作,但在Java servlet中不工作意味着什么?我能看到的唯一区别是HTML头和其他标记(servlet不生成)。当然,JSP不仅响应POST.scriplets,而且对将来的问题也不好,告诉我们错误,而不是忽略它。错误包含问题的答案。您可能会得到一个“HTTP 405 method not allowed”(HTTP 405 method not allowed)错误,它本身就是完整的答案(只需要翻译成外行术语)。+1因为这实际上可能是这个完全不清楚的问题的答案。+1因为这实际上可能是这个完全不清楚的问题的答案。