• 大小: 35KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-13
  • 语言: Java
  • 标签: jsp  servlet  调查问卷  

资源简介

最简单的jsp+servlet实现调查问卷,不需要数据库。

资源截图

代码片段和文件信息

/*
 * To change this template choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Administrator
 */
public class submitServlet extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * GET and
     * POST 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();
        try {
            /* TODO output your page here. You may use following sample code. */
            out.println(““);
            out.println(““);
            out.println(““);
            out.println(“tle>Servlet submitServlettle>“);            
            out.println(““);
            out.println(““);
            out.println(“

Servlet submitServlet at “ + request.getContextPath() + “

“);
            out.println(““);
            out.println(““);
        } finally {            
            out.close();
        }
    }

    @Override
    protected void doGet(HttpServletRequest request HttpServletResponse response)
            throws ServletException IOException {
        processRequest(request response);
    }

 
    @Override
    protected void doPost(HttpServletRequest request HttpServletResponse response)
            throws ServletException IOException {
        //processRequest(request response);
        int s1 = Integer.valueOf(request.getParameter(“radio1“).toString());
        int s2 = Integer.valueOf(request.getParameter(“radio2“).toString());
        int s3 = Integer.valueOf(request.getParameter(“radio3“).toString());
        int s4 = Integer.valueOf(request.getParameter(“radio4“).toString());
        int s5 = Integer.valueOf(request.getParameter(“radio5“).toString());
        int s6 =Integer.valueOf(request.getParameter(“radio6“).toString());
        int s7 = Integer.valueOf(request.getParameter(“radio7“).toString());
        int s8 = Integer.valueOf(request.getParameter(“radio8“).toString());
        int s9 = Integer.valueOf(request.getParameter(“radio9“).toString());
        int s10 = Integer.valueOf(request.getParameter(“radio10“).toString());
        System.out.print(s1);
        int sum=s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;
        if(sum<9){
            request.getRequestDispatcher(“error.jsp“).forward(re

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-06-14 18:57  Question\
     目录           0  2013-06-14 18:57  Question\build\
     文件        3497  2013-06-14 18:51  Question\build.xml
     目录           0  2013-06-14 18:57  Question\build\empty\
     目录           0  2013-06-14 18:57  Question\build\generated-sources\
     目录           0  2013-06-14 18:57  Question\build\generated-sources\ap-source-output\
     目录           0  2013-06-14 20:06  Question\build\web\
     文件         756  2013-06-14 20:09  Question\build\web\1.jsp
     文件         734  2013-06-14 20:09  Question\build\web\2.jsp
     文件         752  2013-06-14 20:09  Question\build\web\3.jsp
     文件         750  2013-06-14 20:09  Question\build\web\4.jsp
     文件         726  2013-06-14 20:09  Question\build\web\error.jsp
     文件           0  2013-06-14 20:13  Question\build\web\gfv3ee6.dpf
     文件        8345  2013-06-14 20:12  Question\build\web\index.jsp
     文件         464  2013-06-14 19:37  Question\build\web\main.css
     目录           0  2013-06-14 18:57  Question\build\web\meta-INF\
     文件          25  2013-06-14 18:57  Question\build\web\meta-INF\MANIFEST.MF
     目录           0  2013-06-14 19:41  Question\build\web\WEB-INF\
     文件         274  2013-06-14 18:57  Question\build\web\WEB-INF\beans.xml
     目录           0  2013-06-14 19:41  Question\build\web\WEB-INF\classes\
     文件           0  2013-06-14 18:57  Question\build\web\WEB-INF\classes\.netbeans_automatic_build
     文件           0  2013-06-14 18:57  Question\build\web\WEB-INF\classes\.netbeans_update_resources
     目录           0  2013-06-14 20:13  Question\build\web\WEB-INF\classes\servlet\
     文件        3267  2013-06-14 20:13  Question\build\web\WEB-INF\classes\servlet\submitServlet.class
     文件         476  2013-06-14 18:57  Question\build\web\WEB-INF\glassfish-web.xml
     文件         673  2013-06-14 19:41  Question\build\web\WEB-INF\web.xml
     目录           0  2013-06-14 18:51  Question\nbproject\
     文件        6784  2013-06-14 18:51  Question\nbproject\ant-deploy.xml
     文件       79789  2013-06-14 18:51  Question\nbproject\build-impl.xml
     文件         473  2013-06-14 18:51  Question\nbproject\genfiles.properties
     目录           0  2013-06-14 20:14  Question\nbproject\private\
............此处省略21个文件信息

评论

共有 条评论