use of javax.servlet.RequestDispatcher in project tesla by linking12.
the class AbstractAuthorizeHandler method submitLogin.
protected boolean submitLogin() throws ServletException, IOException {
if (isSubmitLogin()) {
try {
UsernamePasswordToken token = createUsernamePasswordToken();
SecurityUtils.getSubject().login(token);
LOG.debug("Submit login successful");
this.userFirstLogged = true;
return false;
} catch (Exception ex) {
LOG.debug("Login failed, back to login page too", ex);
final HttpServletRequest request = oauthRequest.request();
request.setAttribute("oauth_login_error", ex.getMessage());
RequestDispatcher dispatcher = request.getRequestDispatcher(OAUTH_LOGIN_VIEW);
dispatcher.forward(request, response);
return true;
}
}
return false;
}
use of javax.servlet.RequestDispatcher in project cxf by apache.
the class RequestDispatcherProvider method writeTo.
public void writeTo(Object o, Class<?> clazz, Type genericType, Annotation[] annotations, MediaType type, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException {
ServletContext sc = getServletContext();
HttpServletRequest servletRequest = getMessageContext().getHttpServletRequest();
String path = getResourcePath(clazz, o);
String theServletPath = servletPath != null ? servletPath : useCurrentServlet ? servletRequest.getServletPath() : "/";
if (theServletPath.endsWith("/") && path != null && path.startsWith("/")) {
theServletPath = theServletPath.length() == 1 ? "" : theServletPath.substring(0, theServletPath.length() - 1);
} else if (!theServletPath.endsWith("/") && path != null && !path.startsWith("/")) {
path = "/" + path;
}
RequestDispatcher rd = getRequestDispatcher(sc, clazz, theServletPath + path);
try {
if (!includeResource) {
getMessageContext().put(AbstractHTTPDestination.REQUEST_REDIRECTED, Boolean.TRUE);
}
HttpServletRequestFilter requestFilter = new HttpServletRequestFilter(servletRequest, path, theServletPath, saveParametersAsAttributes);
String attributeName = getBeanName(o);
if (REQUEST_SCOPE.equals(scope)) {
requestFilter.setAttribute(attributeName, o);
} else if (SESSION_SCOPE.equals(scope)) {
requestFilter.getSession(true).setAttribute(attributeName, o);
}
setRequestParameters(requestFilter);
logRedirection(path, attributeName, o);
if (includeResource) {
rd.include(requestFilter, getMessageContext().getHttpServletResponse());
} else {
rd.forward(requestFilter, getMessageContext().getHttpServletResponse());
}
} catch (Throwable ex) {
handleViewRenderingException(theServletPath + path, ex);
}
}
use of javax.servlet.RequestDispatcher in project quickstart by wildfly.
the class MemberRegistrationServlet method doPost.
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
StringBuilder errorMessage = new StringBuilder();
try {
System.out.println("EMAIL='" + request.getParameter("email") + "'");
Member member;
while ((member = registrationService.getNewMember()) == null) {
registrationService.initNewMember();
}
String value;
if ((value = request.getParameter("name")).length() < 1) {
errorMessage.append("Name can not be null\n");
} else {
member.setName(value);
if ((value = request.getParameter("email")).length() < 1) {
errorMessage.append("email required!\n");
} else {
member.setEmail(value);
if ((value = request.getParameter("phoneNumber")).length() < 1) {
errorMessage.append("phoneNumber required \n");
} else // all parameters are filled, register
{
member.setPhoneNumber(value);
log("\n*****************Try Registration of Member=" + member);
registrationService.register();
request.setAttribute("infoMessage", member.getName() + " Registered!");
}
}
}
} catch (Exception e) {
Throwable t = e;
while ((t.getCause()) != null) {
t = t.getCause();
}
errorMessage.append("Error========>" + t.getMessage());
request.setAttribute("infoMessage", "");
e.printStackTrace();
} finally {
request.setAttribute("errorMessage", errorMessage.toString());
RequestDispatcher resultView = request.getRequestDispatcher("index.jsp");
resultView.forward(request, response);
}
}
use of javax.servlet.RequestDispatcher in project jaffa-framework by jaffa-projects.
the class WebServiceController method doGet.
/**
* @param req. The HttpServletRequest.
* @param resp. The HttpServletResponse
* @throws ServletException
* @throws IOException
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String endPoint = (String) req.getAttribute("realEndPoint");
String uri = "/" + endPoint;
if (log.isDebugEnabled()) {
log.debug("URI :" + uri);
}
RequestDispatcher dispatcher = req.getRequestDispatcher(uri);
if (log.isDebugEnabled()) {
log.debug("Dispatching Request");
}
dispatcher.forward(req, resp);
}
use of javax.servlet.RequestDispatcher in project identity-test-integration by wso2-incubator.
the class OAuth2ClientServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
RequestDispatcher dispatcher = req.getRequestDispatcher("oauth2.jsp");
dispatcher.forward(req, resp);
}
Aggregations