I created : index.jsp in Web Pages , and GetThreeParam.java in Source Package . I can not call GetThreeParam.java from the index.jsp . Please Help me
GetThreeParam.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Du
*/
@WebServlet(name = "GetThreeParam", urlPatterns = {"/GetThreeParam"})
public class GetThreeParam extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
//String title = "Reading three request parameters";
out.println(
"<H1 Align=CENTER>" + "Reading three request parameters" + "</H1>\n" + "<UL>\n"
+ "<LI><B>param1</B>:"
+ request.getParameter("tx1") + "\n"
+ "<LI><B>param2</B>:"
+ request.getParameter("tx2") + "\n"
+ "<LI><B>param3</B>:"
+ request.getParameter("tx3") + "\n"
+ "</UL>\n+</BODY></HTML>");
try {
} finally {
out.close();
}
}
Index.jsp:
<%--
Document : index
Created on : Oct 11, 2012, 2:55:43 AM
Author : Du
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form method="post" action="GetThreeParam.java" >
<div style="width: 1000px;">
<h2>
Collect three Parameter
</h2><hr>
<div style="width: 150px;float: left;line-height: 30px">
First Parameter<br>
Second Parameter<br>
Third Parameter<br>
</div>
<div style="width: 850px;float: left;line-height: 30px">
<input type="text" name="tx1"><br>
<input type="text" name="tx2"><br>
<input type="text" name="tx3"><br>
<input type="submit"></input>
</div>
</div>
</form>
</body>
</html>