Rev 165 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package pt.estgp.estgweb.web;
import org.apache.log4j.Logger;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.FileNotFoundException;
import jomm.web.utils.NavPlace;
/**
* @author Jorge Machado
* @date 26/Fev/2008
* @time 12:46:16
* @see pt.estgp.estgweb.web
*/
public class LayoutProxy
extends HttpServlet
{
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
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(LayoutProxy.
class);
protected void setQueryString
(1.5.0/docs/api/java/lang/String.html">String queryString, HttpServletRequest request
)
{
NavPlace.
setAuxiliaryQueryString(queryString,request
);
}
protected void processRequest
(HttpServletRequest request, HttpServletResponse response
)
throws ServletException,
1.5.0/docs/api/java/io/IOException.html">IOException
{
1.5.0/docs/api/java/lang/String.html">String path = request.
getPathInfo();
int layoutEnd = path.
indexOf("/",1
);
1.5.0/docs/api/java/lang/String.html">String layout = path.
substring(1,layoutEnd
);
logger.
info("layout:" + layout
);
path = path.
substring(layoutEnd
);
int serverEnd = path.
indexOf("/",1
);
if(serverEnd
< 0
)
serverEnd = path.
length();
1.5.0/docs/api/java/lang/String.html">String server = path.
substring(1,serverEnd
);
logger.
info("server:" + server
);
path = path.
substring(serverEnd
);
logger.
info("path:" + path
);
if(path
!=
null)
{
try
{
getServletContext
().
getRequestDispatcher("/layout.do?server=" + server +
"&path=" + path +
"&layout=" + layout +
"&" + request.
getQueryString()).
forward(request,response
);
}
catch(1.5.0/docs/api/java/io/FileNotFoundException.html">FileNotFoundException e
)
{
throw new 1.5.0/docs/api/java/io/FileNotFoundException.html">FileNotFoundException(path
);
}
catch(1.5.0/docs/api/java/lang/Exception.html">Exception e
)
{
throw new 1.5.0/docs/api/java/io/IOException.html">IOException(e.
toString());
}
}
else
{
throw new 1.5.0/docs/api/java/io/FileNotFoundException.html">FileNotFoundException("url not found for server:" + server +
" and path:" + path
);
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet
(HttpServletRequest request, HttpServletResponse response
)
throws ServletException,
1.5.0/docs/api/java/io/IOException.html">IOException
{
processRequest
(request, response
);
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost
(HttpServletRequest request, HttpServletResponse response
)
throws ServletException,
1.5.0/docs/api/java/io/IOException.html">IOException {
processRequest
(request, response
);
}
/** Returns a short description of the servlet.
*/
public 1.5.0/docs/api/java/lang/String.html">String getServletInfo
() {
return "Proxy Servlet to get pages form static web page servers";
}
// </editor-fold>
}