Hi guys,
I noticed that as soon as I add the @Reference annotation in my servlet, the sevlet will not be called when the form is submitted. As soon as I remove @Reference the servlet will be called. But the email will not function because @Reference is required to make the email to work.
I have the servlet registered and briefly it looks like below:
@Service(value = Servlet.class)
@SlingServlet(
resourceTypes = {"myapp/components/content/faqNewQuestions"},
methods = {"POST"},
selectors = {"email"},
extensions = {"html"}
)
@SuppressWarnings("serial")
public class FAQNewQuestionServlet extends SlingAllMethodsServlet {
@Reference
private MessageGatewayService messageGatewayService;
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/plain");
response.getOutputStream().print("FAQNewQuestionServlet is called");
}
}
MessageGatewayService is imported through:
import com.day.cq.mailer.MessageGatewayService;
This package is added to the .bnd file under:
Import-Package: ..., com.day.cq.mailer, org.apache.felix.scr,org.apache.felix.scr.annotations,...
the faqNewQuestions.jsp (which lives under apps/myapp/components/content/faqNewQuestions) has a form looks like this:
<form method="POST" action="<c:out value="${resource.path}" />.email.html">
<input type="text" id="email" name="email"/>
<textarea name="question" id="question"></textarea>
<input class="button" id="questionSubmit" type="submit" value="submit" />
</form>
I just keep getting 'Content modified' page rather seeing the "FAQNewQuestionServlet is called" I was expecting.
Content modified /content/my-trick/jcr:content/par/faqnewquestions
Status | 200 |
Message | OK |
Location | /my-trick/_jcr_content/par/faqnewquestions |
Parent Location | /my-trick/_jcr_content/par |
Really appreciate any inputs..