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

📄 pdaerrorservlet.java

📁 一个简单的java邮件系统
💻 JAVA
字号:
/*
 * @(#)PdaErrorServlet.java
 *
 * Copyright (C) 2006 Sergey Bredikhin
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package olivax.webmail;

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 PdaErrorServlet extends HttpServlet {

	static final long serialVersionUID = 1675075694621323211L;	
	
	public PdaErrorServlet() {
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = null;
		try {
			request.setCharacterEncoding(Context.clntCp);
			response.setContentType("text/html; charset=" + Context.clntCp);			
			out = response.getWriter();
			HttpSession session = request.getSession();
			Context myContext = (Context) session.getAttribute("myContext");
			if(myContext == null) {
				myContext = new Context();
				session.setAttribute("myContext", myContext);
			}
			myContext.setNoCache(response);

			try {
				myContext.mailBean.closeFolder();
				myContext.closeStorage();
			} catch (Exception e) {
				e.printStackTrace();
			}
			Exception exception = (Exception) request.getAttribute("javax.servlet.jsp.jspException");			
			
		    PdaPage pdaPage = new PdaPage();
		    pdaPage.setTitle(myContext.getI18nString("_str_error_title"));
		    
		    //Logo		    		    
		    pdaPage.addPane(myContext.getPdaLogo());
		    
		    //Title
		    PdaPane pdaPane = new PdaPane();
		    pdaPane.setColor(PdaPane.COLOR_CCCCCC);
		    pdaPane.setHeight("20");
		    pdaPane.setContent("<font size=\"3\" face=\"arial, tahoma, verdana\"><strong>" +
		    		myContext.getI18nString("_str_error_title") + "</strong></font>");
		    pdaPage.addPane(pdaPane);		    
		    
		    //Menu
		    StringBuffer sb = new StringBuffer();
		    sb.append("<font size=\"3\">");
		    sb.append("<a href=\"javascript:{history.back();}\">").append(myContext.getI18nString("_str_back")).append("</a>&nbsp; &nbsp;");
		    sb.append("<a href=\"./pda_compose\">").append(myContext.getI18nString("_str_compose")).append("</a>&nbsp; &nbsp;");		    
			sb.append("<a href=\"./pda_list\">").append(myContext.getI18nString("_str_inbox")).append("</a>&nbsp; &nbsp;");						
			sb.append("<a href=\"./pda_logon?action=logout\">").append(myContext.getI18nString("_str_exit")).append("</a>&nbsp; &nbsp;");			
		    sb.append("</font>");
		    
		    PdaPane menuPane = new PdaPane();
		    menuPane.setColor(PdaPane.COLOR_FFFFFF);
		    menuPane.setContent(sb.toString());
		    pdaPage.addPane(menuPane);		    		    			  
		  	
		    // Main page
		    sb = new StringBuffer();			    
		    sb.append(myContext.getI18nString("_str_error_occured")).append(" ").append(myContext.getErrorString(exception));
/*		    
		    sb.append("<div align=\"left\">");
		    sb.append("Stack Trace is : <pre><font color=\"red\" size=\"3\">");
		    String trace = myContext.getStackTrace(exception);
		    if (trace.length() > 500)
				sb.append(trace.substring(0, 500)).append("\n...");
		    else
		    	sb.append(trace);
		    sb.append("</font></pre>");
		    sb.append("</div>");
*/	    
		    pdaPane = new PdaPane();
		    pdaPane.setColor(PdaPane.COLOR_FFFFFF);
		    pdaPane.setContent(sb.toString());
		    pdaPage.addPane(pdaPane);		    		    

		    //Menu
		    pdaPage.addPane(menuPane);
		    
		    //Sublogo
		    pdaPane = new PdaPane();
		    pdaPane.setColor(PdaPane.COLOR_CCFF99);
		    pdaPane.setHeight("20");
		    pdaPane.setContent("<font size=\"3\" color=\"#999966\" face=\"arial, tahoma, verdana\"><strong><i>"
		    		+ myContext.getSenderDomain() + "</i></strong></font>");
		    pdaPage.addPane(pdaPane);		    		    		    
		    
		    pdaPage.show(out);

		    out.flush();
		    out.close();	    		    					    
		} catch (Exception e) {
			try {
				if(out != null)
					e.printStackTrace(out);
				else
					e.printStackTrace();
			} catch (Exception exc) {				
				exc.printStackTrace();				
			}
		}		
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}

⌨️ 快捷键说明

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