1 11 12 package com.espada.bugtracker.servlets; 13 14 import org.webmacro.*; 16 import org.webmacro.broker.*; 17 import org.webmacro.resource.*; 18 import org.webmacro.servlet.WebContext; 19 20 import javax.servlet.http.*; 22 import javax.servlet.*; 23 24 import com.espada.bugtracker.app.*; 26 import com.espada.bugtracker.util.*; 27 28 import org.apache.log4j.*; 30 31 public class StartPage extends BTServlet 32 { 33 34 38 39 40 private static final String defaultTemplate="index.wm"; 41 42 static Category logger = Category.getInstance( StartPage.class.getName() ); 44 45 46 47 private void initConfiguration() 48 { 49 50 57 59 try{ 60 if ( ! PropertyFactory.isInitialized() ) 61 PropertyFactory.readProperties( 62 getServletContext().getRealPath( 63 getServletContext().getInitParameter("btpropfile") 64 ) 65 ); 66 67 } catch (java.io.IOException ioex) { System.out.println("Cannot create props! Big problemo!"); } 68 69 70 71 73 PropertyConfigurator.configure( 74 PropertyFactory.getInstance() ); 75 76 77 78 79 80 81 } 83 84 86 public void doGet(HttpServletRequest req, HttpServletResponse resp) 87 { 88 initConfiguration(); 90 91 try 92 { 93 try 94 { 95 96 WebContext c = _wm.getWebContext(req,resp); 98 99 100 101 HttpSession session = req.getSession(); 102 103 logger.debug("Invalidated HttpSession."); 104 105 session.invalidate(); 107 session = req.getSession(true); boolean loggedIn = false; 109 String s = "http://" + req.getServerName(); 110 111 session.setAttribute("loggedIn",String.valueOf(loggedIn)); 112 c.put("serverName", s); 113 c.put("loggedIn",String.valueOf(loggedIn)); 114 115 116 117 Template t = _wm.getTemplate(defaultTemplate); 119 120 FastWriter fw = new FastWriter(resp.getOutputStream(),resp.getCharacterEncoding()); 122 123 t.write(fw, c); 125 fw.close(); 126 127 128 129 } 130 catch (org.webmacro.NotFoundException e) 131 { 132 133 FastWriter out = new FastWriter(resp.getOutputStream(),resp.getCharacterEncoding()); 134 135 out.write("ERROR! Could not locate template " + defaultTemplate + ", check that your template path is set properly in WebMacro.properties"); 136 137 out.close(); 138 139 } 140 catch (org.webmacro.ContextException e) 141 { 142 143 FastWriter out = new FastWriter(resp.getOutputStream(),resp.getCharacterEncoding()); 144 145 out.write("ERROR! Could not locate required data in the Context."); 146 147 out.close(); 148 } 149 } 150 catch (java.io.IOException e) 151 { 152 153 System.out.println("ERROR: IOException while writing to servlet output stream."); 155 156 } 157 158 } 160 161 } | Popular Tags |