📄 setwriteletterloadinfoservlet.java
字号:
package com.lovo.controller;
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;
import javax.servlet.http.HttpSession;
public class SetWriteLetterLoadInfoServlet extends HttpServlet
{
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
/** 设置响应文件类型及字符集编码 */
response.setContentType("text/xml; charset=utf-8");
/** 设置响应头,让浏览器不缓存信息 */
response.setHeader("Cache-control", "no-cache");
/** 获得设置指示信息 */
String flag = request.getParameter("operation");
/** 获得当前会话 */
HttpSession session = request.getSession();
/** 通过点击'写信'按钮加载writeLetter页面的话,将currentMail清空 */
if(flag.equals("write"))
{
/** 清空当前查看的邮件 */
session.removeAttribute("currentMail");
}
/** 通过草稿箱加载writeLetter页面的话,将加载信息放入会话 */
if(flag.equals("draft"))
{
session.setAttribute("loadInfo", "draft");
}
/** 通过已发送加载writeLetter页面的话,将加载信息放入会话 */
if(flag.equals("sended"))
{
session.setAttribute("loadInfo", "sended");
}
/** 通过收件箱、收信、已删除加载writeLetter页面的话,将加载信息放入会话 */
if(flag.equals("other"))
{
session.setAttribute("loadInfo", "other");
}
if(flag.equals("contact"))
{
session.setAttribute("loadInfo", "contact");
String names = request.getParameter("emailNames");
String[] temp = names.split(",");
String emailNames = "";
for(int i = 0; i < temp.length; i++)
{
emailNames += temp[i] + ";";
}
session.setAttribute("receiveMan", emailNames);
}
session.removeAttribute("isUpdate");
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -