I am just starting with Servlets/JSP/JSTL and I have something like this:
<html>
<body>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:directive.page contentType="text/html; charset=UTF-8" />
<c:choose>
<c:when test='${!empty login}'>
zalogowany
</c:when>
<c:otherwise>
<c:if test='${showWarning == "yes"}'>
<b>Wrong user/password</b>
</c:if>
<form action="Hai" method="post">
login<br/>
<input type="text" name="login"/><br/>
password<br/>
<input type="password" name="password"/>
<input type="submit"/>
</form>
</c:otherwise>
</c:choose>
</body>
</html>
and in my doPost method
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
HttpSession session=request.getSession();
try
{
logUser(request);
}
catch(EmptyFieldException e)
{
session.setAttribute("showWarning", "yes");
} catch (WrongUserException e)
{
session.setAttribute("showWarning", "yes");
}
RequestDispatcher d=request.getRequestDispatcher("/index.jsp");
System.out.println("z");
d.forward(request, response);
}
but something is not working, because I wanted something like this:
- if user had active session and was logged to system "zalogowany" should show
- otherwise logging form
the problem is whatever I do, those forwards don't put me to index.jsp, which is in root folder of my Project, I still have in my address bar Projekt/Hai.