Reputation: 13395
For example on every page I allow user to authorize himself. But in action LoginAction
I move him to main.jsp
every time because req.getRequestURI
returns url with action in it
localhost:8080/reservation/LoginAction.do
.
Here is LoginAction
HttpSession session = req.getSession();
log.debug("attempt to checkuser");
String login = req.getParameter("login");
String password = req.getParameter("password");
if (loginService.checkExists(login, password)) {
session.setAttribute("enterAttr", true);
session.setAttribute("loginame", login);
return "main";
}
session.setAttribute("enterAttr", false);
return "redirect:/reservation/main.jsp";
How to get page that cause action?
Form on page looks like this
<form action="LoginAction.do" method="POST">
<div id="table"
class="ui-widget-header ui-corner-all ui-widget-content">
<table align="center" style="width: 100%">
<tr>
<td align="center"><span
style="color: white; font-size: 20px;"><fmt:message
key="lg" /></span></td>
<td align="right"><input type="text" id="login" name="login" />
<td>
</tr>
<tr>
<td align="center"><span
style="color: white; font-size: 20px;"><fmt:message
key="paswd" /></span></td>
<td align="right"><input type="password" id="password"
name="password" /></td>
</tr>
<tr>
<td align="right" colspan="2"><input type="submit"
id="approve" style="font-size: 10px;"
value="<fmt:message key='enter'/>" /></td>
</tr>
</table>
</div>
</form>
Upvotes: 0
Views: 1198
Reputation: 9527
When I am using this, I have hidden filed in form, that contains actual URL (or page). After login user, I use that value to redirect to last page.
<input type="hidden" name="redirect_page" value="some_info" />
Upvotes: 1