📄 userpreference.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.horizongroup.mcompanion.web.model;import com.horizongroup.mcompanion.web.db.DBManager;import java.io.*;import java.net.*;import javax.servlet.*;import javax.servlet.http.*;/** * * @author Administrator */public class UserPreference extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String preference =""; String type=""; String name =""; String str1 = request.getParameter("input"); // out.println("dfjasdhfjsdj"); // String pref = "empty";// if(request.getSession().getAttribute("current_criteria") != null){// pref = request.getSession().getAttribute("current_criteria").toString();// }// out.println(pref); String[] str = request.getParameter("input").split(":"); out.println("Lengtsdash =" + str.length); // if(str[0].equals("preference")) { // preference = request.getSession().getAttribute("current_criteria").toString(); preference = str[1]+":"+str[2]+":"+str[3] ; type = "Criteria"; name = str[4]; } else if(str[0].equals("location")) { // preference = request.getSession().getAttribute("current_location").toString(); preference = str[2]+":"+str[3] ; type = "Location"; name =str[1]; } new DBManager().savePreferences(name, preference, type); try { } 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 + -