Last active
March 23, 2016 15:28
-
-
Save auniverseaway/fa55ad45e809e7bf1134 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.millr.core.servlets; | |
import java.io.IOException; | |
import java.rmi.ServerException; | |
import org.apache.felix.scr.annotations.sling.SlingServlet; | |
import org.apache.sling.api.SlingHttpServletRequest; | |
import org.apache.sling.api.SlingHttpServletResponse; | |
import org.apache.sling.api.servlets.SlingAllMethodsServlet; | |
import org.apache.sling.commons.json.JSONObject; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
/** | |
* A simple servlet to receive a POSTed email address and return it as a JSON object. | |
*/ | |
@SlingServlet(paths="/bin/registerUser", methods="POST", metatype=false) | |
public class UserRegistrationServlet extends SlingAllMethodsServlet { | |
/** The Constant LOGGER. */ | |
private static final Logger LOGGER = LoggerFactory.getLogger(UserRegistrationServlet.class); | |
/** The Constant serialVersionUID. */ | |
private static final long serialVersionUID = 1L; | |
@Override | |
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServerException, IOException { | |
LOGGER.info(">>>>>> In doPost"); | |
try | |
{ | |
String email = request.getParameter("email"); | |
LOGGER.info("Email Adress: " + email); | |
JSONObject json = new JSONObject(); | |
json.put("email", email); | |
response.setContentType(""); | |
response.getWriter().write(json.toString()); | |
} | |
catch(Exception e) | |
{ | |
e.printStackTrace(); | |
} | |
LOGGER.info(">>>>>> Leaving doPost"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment