www.pudn.com > Jsp-Blog.rar > ShowPhotoServlet.java, change:2010-05-26,size:1197b


package myblog.servlet; 
 
import java.io.IOException; 
import java.util.ArrayList; 
 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import myblog.dao.ShowPhotoDao; 
import myblog.entity.Photos; 
 
public class ShowPhotoServlet extends HttpServlet { 
	 
public void doGet(HttpServletRequest request, 
		HttpServletResponse response){ 
	doPost(request,response); 
	 
} 
	public void doPost(HttpServletRequest request, 
			HttpServletResponse response) { 
		ShowPhotoDao photo = new ShowPhotoDao(); 
		ArrayList<Photos> list = new ArrayList<Photos>(); 
		String username = request.getSession().getAttribute("username") 
				.toString(); 
		if (username.equals("tourist")) { 
			username = "xiaoqiang"; 
			list = photo.showPhotos(username); 
		} else { 
			list = photo.showPhotos(username); 
		} 
		request.setAttribute("photolist", list); 
 
		try { 
			request.getRequestDispatcher("showphoto.jsp").forward(request, 
					response); 
		} catch (ServletException e) { 
 
			e.printStackTrace(); 
		} catch (IOException e) { 
 
			e.printStackTrace(); 
		} 
	} 
 
}