Rev 1945 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
249 | jmachado | 1 | package pt.estgp.estgweb.web; |
2 | |||
3 | import org.apache.log4j.Logger; |
||
4 | import pt.estgp.estgweb.web.controllers.courseunits.CourseUnitLayoutProxy; |
||
5 | import pt.estgp.estgweb.web.exceptions.InternalException; |
||
6 | |||
7 | import javax.servlet.ServletException; |
||
8 | import javax.servlet.http.HttpServletRequest; |
||
9 | import javax.servlet.http.HttpServletResponse; |
||
10 | import java.io.IOException; |
||
11 | import java.util.Enumeration; |
||
12 | |||
13 | /** |
||
14 | * @author Jorge Machado |
||
15 | * @date 26/Fev/2008 |
||
16 | * @time 12:46:16 |
||
17 | * @see pt.estgp.estgweb.web |
||
18 | */ |
||
19 | public class StartPathLayoutProxy extends LayoutProxy |
||
20 | { |
||
21 | |||
22 | /** |
||
851 | jmachado | 23 | * sss requests for both HTTP <code>GET</code> and <code>POST</code> methods. |
249 | jmachado | 24 | * |
25 | * @param request servlet request |
||
26 | * @param response servlet response |
||
27 | */ |
||
28 | |||
29 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CourseUnitLayoutProxy.class); |
||
30 | |||
31 | |||
32 | protected void processRequest(HttpServletRequest request, HttpServletResponse response) |
||
33 | throws ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException |
||
34 | { |
||
35 | try |
||
36 | { |
||
37 | 1.5.0/docs/api/java/lang/String.html">String startPath = request.getParameter("startPath"); |
||
38 | if (startPath != null) |
||
39 | { |
||
40 | request.setAttribute("startPath", startPath); |
||
41 | startPath = "startPath=" + startPath; |
||
42 | } |
||
43 | else |
||
44 | startPath = ""; |
||
45 | 1.5.0/docs/api/java/lang/String.html">String from = ""; |
||
46 | if (request.getParameter("from") != null) |
||
47 | from = "&from=" + request.getParameter("from"); |
||
48 | |||
49 | 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder queryString = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder(); |
||
50 | queryString.append(startPath + from); |
||
51 | Enumeration<String> enumeration = request.getParameterNames(); |
||
52 | while(enumeration.hasMoreElements()) |
||
53 | { |
||
54 | 1.5.0/docs/api/java/lang/String.html">String attr = enumeration.nextElement(); |
||
55 | if(attr.startsWith("nav")) |
||
56 | { |
||
57 | queryString.append("&").append(attr).append("=").append(request.getParameter(attr)); |
||
58 | } |
||
59 | } |
||
60 | super.setQueryString(queryString.toString(), request); |
||
61 | super.processRequest(request, response); |
||
62 | } |
||
63 | catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
64 | { |
||
65 | logger.error(e, e); |
||
66 | throw new InternalException(e.toString()); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> |
||
71 | /** |
||
72 | * Handles the HTTP <code>GET</code> method. |
||
73 | * |
||
74 | * @param request servlet request |
||
75 | * @param response servlet response |
||
76 | */ |
||
77 | protected void doGet(HttpServletRequest request, HttpServletResponse response) |
||
78 | throws ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException |
||
79 | { |
||
80 | processRequest(request, response); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Handles the HTTP <code>POST</code> method. |
||
85 | * |
||
86 | * @param request servlet request |
||
87 | * @param response servlet response |
||
88 | */ |
||
89 | protected void doPost(HttpServletRequest request, HttpServletResponse response) |
||
90 | throws ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException |
||
91 | { |
||
92 | processRequest(request, response); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Returns a short description of the servlet. |
||
97 | */ |
||
98 | public 1.5.0/docs/api/java/lang/String.html">String getServletInfo() |
||
99 | { |
||
100 | return "Proxy Servlet to get pages form static web page servers"; |
||
101 | } |
||
102 | // </editor-fold> |
||
103 | } |