这样的servlet和JSP页面,怎么配置xml?
servlet是在包abc中各地方都表示什么?
<servlet>
<servlet-name></servlet-name>//代表什么?
<servlet-class>abc.Sqrt</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
jsp
<%@ page contentType="text/html;charset=GB2312"%>
<HTML>
<BODY>
<Table align=center>
<TR>
<TH>
输入一个数,求这个数的平方根
</TH>
</TR>
<TR>
<TD>
<FORM method=post action="servlet/Sqrt">
<INPUT type=text name="number">
<INPUT type=submit name="submit" value="提交">
</FORM>
</TD>
</TR>
</Table>
</BODY>
</HTML>Sqrt.java
package abc;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Sqrt extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void service(HttpServletRequest request,HttpServletResponse response) throws IOException
{
PrintWriter out = response.getWriter();
response.setContentType("text/html;charset=GB2312");
out.print("<html><body>");
out.print("Simple servlet");
String number = request.getParameter("number");
double n = 0;
try
{
n = Double.parseDouble(number);
out.print(number);
out.print("<BR>"+Math.sqrt(n));
}
catch(NumberFormatException e)
{
out.print("<H1>input number letter please!</H1>");
}
out.print("</body></html>");
}
}