11package etu2024 .framework .servlet ;
22
33import com .google .gson .Gson ;
4- import etu2024 .framework .annotation .Auth ;
54import etu2024 .framework .annotation .RestAPI ;
65import etu2024 .framework .annotation .Session ;
76import etu2024 .framework .annotation .Singleton ;
1413import jakarta .servlet .*;
1514import jakarta .servlet .annotation .MultipartConfig ;
1615import jakarta .servlet .http .*;
17- import org .eclipse .jdt .internal .compiler .codegen .ObjectCache ;
1816
1917import java .io .IOException ;
2018import java .lang .reflect .Field ;
2119import java .lang .reflect .InvocationTargetException ;
2220import java .lang .reflect .Method ;
2321import java .lang .reflect .Parameter ;
24- import java .net .http .HttpRequest ;
2522import java .util .*;
2623
2724@ MultipartConfig
@@ -35,6 +32,7 @@ public void init() throws ServletException {
3532 // Get the mapping urls from the package root set in the web.xml
3633 setMappingUrls (Mapping .getAnnotatedUrlMethod (getInitParameter ("PACKAGE_ROOT" )));
3734 setInstances (new HashMap <>());
35+ Conf .CONFIG_FILE = getInitParameter ("CONFIG_FILE" );
3836 }
3937
4038 @ Override
@@ -53,6 +51,11 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
5351 // Get the url from the request
5452 String request_url = request .getRequestURL ().toString ().split (request .getContextPath ())[1 ];
5553
54+ if (request_url .contains ("." )) {
55+ // send to default servlet
56+ getServletContext ().getNamedDispatcher ("default" ).forward (request , response );
57+ }
58+
5659 // Get the mapping from the url
5760 Mapping mapping = getMappingUrls ().get (request_url );
5861
@@ -112,7 +115,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
112115 // Check if client authorized to call the method (if the method is annotated with @Auth)
113116 Object profile = session .getAttribute (Conf .getAuthSessionName ());
114117 if (!User .isAuthorized (method , profile )) {
115- response .sendRedirect (getServletContext () .getContextPath ()+Conf .getAuthRedirections ().get ("AUTH_REDIRECT_LOGOUT" ));
118+ response .sendRedirect (request .getContextPath ()+Conf .getAuthRedirections ().get ("AUTH_REDIRECT_LOGOUT" ));
116119 return ;
117120 }
118121
@@ -128,9 +131,9 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
128131
129132 // Forward the request if view is set in the modelView
130133 if (modelView .getView () != null ) {
131- if (modelView .isRedirect ())
132- response .sendRedirect (getServletContext () .getContextPath ()+ modelView .getView ());
133- else
134+ if (modelView .isRedirect ()) {
135+ response .sendRedirect (request .getContextPath () + modelView .getView ());
136+ } else
134137 request .getRequestDispatcher (modelView .getView ()).forward (request , response );
135138 }
136139
0 commit comments