JSP中创建一个Servelt。要求通过在浏览器中访问该servlet后,输出一个一行一列的表格
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
4个回答
展开全部
import java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;
public class HelloWorldExample extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException
{
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());
response.setContentType("text/html"); 2’
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
String title = rb.getString("helloworld.title");
out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">"); 3’
out.println("<table><tr><td>保护环境!爱护地球! </td></tr></table>"); 3’
out.println("<h1>" + title + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
public class HelloWorldExample extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException
{
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());
response.setContentType("text/html"); 2’
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
String title = rb.getString("helloworld.title");
out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">"); 3’
out.println("<table><tr><td>保护环境!爱护地球! </td></tr></table>"); 3’
out.println("<h1>" + title + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
@WebServlet("/MyServlet")
public class MyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException{
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.println("<table border=1> <tr><td>保护环境,爱护地球! </td></tr></table>");
}
}
public class MyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException{
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.println("<table border=1> <tr><td>保护环境,爱护地球! </td></tr></table>");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
jsp中创建servlet? 不知道是我基础不够好还是我没理解这句话,我只知道jsp就是servlet的简化版,为什么要jsp创建servlet
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个可以写· see my name .. find me
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询