Dear All,
I have one requirement for my password reset page.
1) When User click on password reset URL (For example http://localhost:4502/content/sunita/passwordReset.html?sunitauniqueid=12344fhjiikj3455) , then I need to call this sunitauniqueid param in my servlet code and can get the requestedUserID by using some below code.
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@component(immediate = true,
service = Servlet.class,
property = {"sling.servlet.paths=/bin/sunita/rest/password-reset",
"sling.servlet.methods=POST"})
public class SunitaPwdResetGetServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(SunitaPwdResetGetServlet.class);
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException {
PrintWriter respWriter = null;
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build())
{
respWriter = response.getWriter();
String requestedUserID = request.getParameter("sunitauniqueid");
log.info("userName ======= "+ requestedUserID);
}
catch (IOException e) {
log.error("Error in Password Reset", e);
} finally {
if (respWriter != null) {
response.setContentType("application/json");
respWriter.print("{}");
respWriter.flush();
respWriter.close();
}
}
}
}
2) Now , I want to display this requestedUserID from my above servlet code to my Frontend ,like below.
My HTL code is below..I have hard coded here the requestedUserID value.How can I get my requestedUserID in my frontEnd ?
<div class="requestedUserIDContainer">
<h1>requestedUserID = *****1234</h1>
</div>
Please help me on this
Thanks In advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Here's what you can try:
I hope this helps,
Brian.
Here's what you can try:
I hope this helps,
Brian.
Can you please give me the example for below 2 points.
Views
Replies
Total Likes