Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Dispatch request to a page component from Servlet

Avatar

Level 3

Hi,

How to I dispatch a request to a page component (JSP)? I get the following error javax.jcr.nodetype.ConstraintViolationException: no matching property definition found for {}country. I don't want the country value to be persisted.

The code I used to dispatch from the servlet is:

RequestDispatcher dispatcher = request.getRequestDispatcher("/content/mycompany/cars/audi/a4.html");
dispatcher.forward(request, response);

Thanks you.

Cheers,

Viren.

1 Accepted Solution

Avatar

Correct answer by
Level 3

What I did was use the SlingHttpServletRequestWrapper class to convert the form method to GET from POST and then dispatch it. The below code worked for me.

org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper req = new org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper(request) { public String getMethod() { return "GET"; } }; String path = "/content/mycompany/shippingDetails.html"; javax.servlet.RequestDispatcher dispatcher = request.getRequestDispatcher(path); dispatcher.include(req, response);

View solution in original post

0 Replies

Avatar

Correct answer by
Level 3

What I did was use the SlingHttpServletRequestWrapper class to convert the form method to GET from POST and then dispatch it. The below code worked for me.

org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper req = new org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper(request) { public String getMethod() { return "GET"; } }; String path = "/content/mycompany/shippingDetails.html"; javax.servlet.RequestDispatcher dispatcher = request.getRequestDispatcher(path); dispatcher.include(req, response);

Avatar

Level 10

It seems you are posting to a page resource url directly. If you are not persisting why are you using post request.

Avatar

Level 10

According to this illustration located here http://dev.day.com/docs/en/cq/current/deploying/dispatcher.html:

[img]dd.png[/img]

Dispatcher goes through a flowchart to determine if the page is cached or not. Have you ensured that the Dispatcher is properly configured. Please read this AEM Topic:

http://dev.day.com/docs/en/cq/current/deploying/dispatcher/disp_config.html