I have an application that uses jsps and servlets. While debugging the application I can find a request that does not have any parameters and hence it lands to the error page. Does anyone have any idea..how can we debug it so as to know from where the request is coming?
Asked
Active
Viewed 95 times
0
-
Hi Jarrod, I think use case of both the questions are different. Here he/she just want to see what is coming as part of the request. In the other question, user is asking how to do filter work and request processing in parallel. If you are convinced, pls. remove the duplicate. – thangamanikasi Sep 30 '14 at 11:28
2 Answers
0
You can write a filter , and then you can print all the parameters of request via it.

yunnysunny
- 183
- 1
- 15
-
I have done that..the request url shows as application/controller while there are no parameters present in the request. – mona Sep 29 '14 at 09:18
0
You can use the filters for your use case. You can take control of the request object inside doFilter method.
In Web.xml
<filter>
<filter-name>myFilter</filter-name>
<filter-class>ServletInterceptor</filter-class>
</filter>
<filter-mapping>
<filter-name>myFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
Filter Class:
public class ServletInterceptor implements Filter
{
//// ************
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException
{
System.out.println("Request(" + (++i) + ") :: " + ((HttpServletRequest) request).getRequestURL());
System.out.println("Get Canonical Name :: " + request.getClass().getCanonicalName());
filterChain.doFilter(request, response);
}
}

thangamanikasi
- 846
- 6
- 19
-
from request URL I can only find an URL pointing to the controller..something like application/controller. I am still unable to find from where this request is generating. – mona Sep 29 '14 at 08:35
-
doFilter(request,response). In this request object will give your complete request in the Java Object Form. Refer the attached link. http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html – thangamanikasi Sep 30 '14 at 01:16