showprofile.java

来自「JSP_博客网站系统,功能完整。学习JSP的好资料。开发时采用Eclipse+M」· Java 代码 · 共 62 行

JAVA
62
字号
package huc.blog.servlet;

import huc.blog.bean.User;
import huc.blog.op.UserOp;
import huc.blog.util.ParamUtils;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ShowProfile extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 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 {
		doPost(request, response);
	}

	/**
	 * 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 {
		
		String userid = ParamUtils.getParameter(request, "userid", "");
		
		//获得该空间的主人的相关信息
		UserOp userOp = new UserOp();
		User user = userOp.getUserById(userid);
        //更新点击率
        userOp.updateHit(userid);
		
		request.setAttribute("user", user);
		request.getRequestDispatcher("../profile.jsp").forward(request, response);
	}

}

⌨️ 快捷键说明

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