Hi all,
I have been working on converting a custom form component from a GET to a POST action. Using the following forum discussion from last year: http://forums.adobe.com/thread/1120136, I modified my existing servlet to intercept the POST. It works great on my author server, but it will not work at all on my publish instance. Essentially, my servlet extends SlingAllMethodsServlet, but doPost is never called on in Publish but it is called in Author.
Is there something obvious that I am missing?
Here are some of my code snippets:
<form action="/my/content/path.feedbacksurveysubmit.html" id="feedbacksurveyform" name="feedbacksurveyform" method="post"> ... <input type="submit" value="Send My Response"/> </form>
@Component(immediate = true, metatype = false, label="FeedbackSurveyServlet") @Service @Properties(value = { @org.apache.felix.scr.annotations.Property(name = "sling.servlet.methods", value = { "POST" }), @org.apache.felix.scr.annotations.Property(name = "sling.servlet.resourceTypes", value = { "sling/servlet/default" }), @org.apache.felix.scr.annotations.Property(name = "sling.servlet.selectors", value = { FeedbackConstants.FEEDBACK_SURVEY_FORM_SUBMIT }), @org.apache.felix.scr.annotations.Property(name = "sling.servlet.extensions", value = { "html" }) }) public class FeedbackSurveyServlet extends AbstractComponentServlet { ... @Override public void process(final ComponentRequest request) throws ServletException, IOException { /*here, I send the relevant data to our backend system*/ } }
public abstract class AbstractComponentServlet extends SlingAllMethodsServlet { ... @Override protected final void doPost(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException { LOG.debug("doPost()"); // NOTE: the publish instance never hits this, while author goes all the way through final ComponentRequest componentRequest = new ComponentRequestImpl(request, response); process(componentRequest); } }
Solved! Go to Solution.
There are several possible reasons that I can think of:
I'd check your error logs on your publish servers (the referrer filter error will show up for example). If you don't see anything in there I'd check you access.log to make sure the POST request is actually getting back to your publish server, and that your publish server is receiving the URL you expect. Also I'd check two things in Felix - is your servlet active, and also check the recent requests page to see what servlet is handling the request - that might help identify the problem.
There are several possible reasons that I can think of:
I'd check your error logs on your publish servers (the referrer filter error will show up for example). If you don't see anything in there I'd check you access.log to make sure the POST request is actually getting back to your publish server, and that your publish server is receiving the URL you expect. Also I'd check two things in Felix - is your servlet active, and also check the recent requests page to see what servlet is handling the request - that might help identify the problem.
Thanks, for the suggestions orotas! I will go that route and see what I find.
Views
Replies
Total Likes
The referrer filter suggestion definitely tipped me in the right direction for the solution. I realized that he form action was actually a fully qualified path sub domain and all (in my original post I put a relative path as the action, but in reality the path was not relative at all). When I changed the action to be a relative path, the POST went through as expected on the publish instance.
Thanks again, orotas, for the suggestions!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies