⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texthandler.java

📁 网络商店源代码用NetBeans6.1Beta开发
💻 JAVA
字号:
package servlet;import java.io.*;import java.net.*;import javax.servlet.*;import javax.servlet.http.*;import java.math.BigDecimal;import model.*;import org.apache.commons.lang.StringEscapeUtils;public class TextHandler extends HttpServlet {  protected void processRequest(HttpServletRequest request, HttpServletResponse response)          throws ServletException, IOException {    response.setContentType("text/html;charset=UTF-8");    PrintWriter out = response.getWriter();    try {             String tf = request.getParameter("tf");      String ta = request.getParameter("ta");      String raw_button = request.getParameter("raw_button");      String tf_esc = StringEscapeUtils.escapeHtml(tf);      String ta_esc = StringEscapeUtils.escapeHtml(ta);      String tf_ins;      String ta_ins;      String title;      if (raw_button != null) {        title = "Raw input inserted";        tf_ins = tf;        ta_ins = ta;      } else {        title = "Escaped input inserted";        tf_ins = tf_esc;        ta_ins = ta_esc;      }                     ProductsBean pb = (ProductsBean) request.getSession().getAttribute("pb");      if (pb == null) {        pb = new ProductsBean();        request.getSession().setAttribute("pb", pb);      }      OrdersBean ob = (OrdersBean) request.getSession().getAttribute("ob");      if (ob == null) {        ob = new OrdersBean();        request.getSession().setAttribute("ob", ob);      }              out.println("*** Add new product<br />");      Product[] samples = {        new Product(ta_ins, new BigDecimal(tf_ins)),            };      for (Product p : samples) pb.create(p);    }     catch (Exception x) {      x.printStackTrace();    }     finally {      out.close();    }  }  // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">  /**    * Handles the HTTP <code>GET</code> method.   * @param request servlet request   * @param response servlet response   */  protected void doGet(HttpServletRequest request, HttpServletResponse response)          throws ServletException, IOException {    processRequest(request, response);  }  /**    * Handles the HTTP <code>POST</code> method.   * @param request servlet request   * @param response servlet response   */  protected void doPost(HttpServletRequest request, HttpServletResponse response)          throws ServletException, IOException {    processRequest(request, response);  }  /**    * Returns a short description of the servlet.   */  public String getServletInfo() {    return "Short description";  }  // </editor-fold>}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -