Re: Tuckey Rewrite URL and infinite loop exception trace for Tomcat 7.0.57

2016-04-25 Thread Kiran Badi
I resolved it.My bad, to and from rule were having same url mapping and I
feel thats the reason it filter was recursively called and finally
resulting into stackoverflow error.

On Mon, Apr 25, 2016 at 7:02 PM, Kiran Badi  wrote:

> Hi,
>
> I am having some issues with  Tuckey Rewrite URL/Tomcat 7.0.57 and for
> some reasons I believe I am not getting it correct. It seems to me that I
> am getting into infinite loop somewhere.Not sure why but conditions do
> match.
>
>
>  Hello World! This is a link I am
> trying to clean it.
>
> Below is test servlet.
>
>
>  protected void processRequest(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException {
> response.setContentType("text/html;charset=UTF-8");
> try (PrintWriter out = response.getWriter()) {
> String[] params =
> request.getPathInfo().substring(1).split("/");
> System.out.println(params[0]);
> String testid = request.getParameter("testid");
> RequestDispatcher rd =
> request.getRequestDispatcher("/WEB-INF/views/Hello.jsp");
> rd.include(request, response);
> }
> }
>
>
> 
>  http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd;>
>
> 
> 
>
> 
> 
> The rule means that requests to /test/status/ will be
> redirected to /rewrite-status
> the url will be rewritten.
> 
> /test/status/
> %{context-path}/rewrite-status
> 
> 
>  Sample redirect
>  operator="equal">[0-9]
> ^/GetServlet(.*)$
> /GetServlet/testid/%{parameter:testid}
> 
>
> 
> 
> The outbound-rule specifies that when response.encodeURL is
> called (if you are using JSTL c:url)
> the url /rewrite-status will be rewritten to /test/status/.
>
> The above rule and this outbound-rule means that end users
> should never see the
> url /rewrite-status only /test/status/ both in thier location
> bar and in hyperlinks
> in your pages.
> 
> /rewrite-status
> /test/status/
> 
> 
>
>
>
>
>
>
> INFO: org.tuckey.web.filters.urlrewrite.substitution.VariableReplacer
> DEBUG: variable %{parameter:testid} type: parameter, name: 'testid'
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.substitution.VariableReplacer
> DEBUG: resolved to: 50
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.substitution.VariableReplacer
> DEBUG: replaced sb is /GetServlet/testid/50
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs
> to be forwarded to /GetServlet/testid/50
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG:
> looking for hostname match on current server name localhost
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking
> for status path on /cleanurl/GetServlet/testid/50
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing
> request for /GetServlet/testid/50
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: query string
> added
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 0 run called
> with /GetServlet/testid/50?testid=50
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Sample redirect
> (rule 1) run called with /GetServlet/testid/50?testid=50
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating "50"
> against [0-9]
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
> INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: conditions match
> Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationDispatcher
> invoke
> SEVERE: Servlet.service() for servlet default threw exception
> java.lang.StackOverflowError
> at
> org.apache.catalina.connector.Request.notifyAttributeAssigned(Request.java:1547)
> at org.apache.catalina.connector.Request.setAttribute(Request.java:1538)
> at
> org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:541)
> at
> 

Tuckey Rewrite URL and infinite loop exception trace for Tomcat 7.0.57

2016-04-25 Thread Kiran Badi
Hi,

I am having some issues with  Tuckey Rewrite URL/Tomcat 7.0.57 and for some
reasons I believe I am not getting it correct. It seems to me that I am
getting into infinite loop somewhere.Not sure why but conditions do match.


 Hello World! This is a link I am trying
to clean it.

Below is test servlet.


 protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String[] params = request.getPathInfo().substring(1).split("/");
System.out.println(params[0]);
String testid = request.getParameter("testid");
RequestDispatcher rd =
request.getRequestDispatcher("/WEB-INF/views/Hello.jsp");
rd.include(request, response);
}
}



http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd;>






The rule means that requests to /test/status/ will be
redirected to /rewrite-status
the url will be rewritten.

/test/status/
%{context-path}/rewrite-status


 Sample redirect
[0-9]
^/GetServlet(.*)$
/GetServlet/testid/%{parameter:testid}




The outbound-rule specifies that when response.encodeURL is
called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/.

The above rule and this outbound-rule means that end users
should never see the
url /rewrite-status only /test/status/ both in thier location
bar and in hyperlinks
in your pages.

/rewrite-status
/test/status/








INFO: org.tuckey.web.filters.urlrewrite.substitution.VariableReplacer
DEBUG: variable %{parameter:testid} type: parameter, name: 'testid'
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.substitution.VariableReplacer
DEBUG: resolved to: 50
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.substitution.VariableReplacer
DEBUG: replaced sb is /GetServlet/testid/50
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleExecutionOutput DEBUG: needs to
be forwarded to /GetServlet/testid/50
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.utils.ServerNameMatcher DEBUG:
looking for hostname match on current server name localhost
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.UrlRewriteFilter DEBUG: checking
for status path on /cleanurl/GetServlet/testid/50
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing
request for /GetServlet/testid/50
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: query string
added
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Rule 0 run called
with /GetServlet/testid/50?testid=50
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Sample redirect
(rule 1) run called with /GetServlet/testid/50?testid=50
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: matched "from"
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.Condition DEBUG: evaluating "50"
against [0-9]
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: conditions match
Apr 25, 2016 6:38:41 PM org.apache.catalina.core.ApplicationDispatcher
invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.StackOverflowError
at
org.apache.catalina.connector.Request.notifyAttributeAssigned(Request.java:1547)
at org.apache.catalina.connector.Request.setAttribute(Request.java:1538)
at
org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:541)
at
org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:288)
at
org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:288)
at
org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:288)
at
org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:288)
at
org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:288)
at