I am fetching username and password from semnatic ui modal login form (home.jsp) in servlet. Servlet will verify the credentials and return result to home.jsp the error should be displayed in the same modal. The error message is not displayed in first run in the modal it gets displayed when I again click on login button which opens this modal. I want this error message in first run. Please suggest how to achieve this. Below is the complete code.
FileBug.java (Servlet)
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
Bugzilla bugzilla=Bugzilla.getBugzillaInstance("username", "pass");
try {
//some code
}catch(Exception e)
{
request.setAttribute("errorMessage",e.getMessage());
RequestDispatcher dispatcher = request.getRequestDispatcher("/home.jsp");
dispatcher.forward(request, response);
}
}
home.jsp
<a class="item agenda-item" id="test">
<span class="side-agenda-item"> <i class="bug icon"></i> File a Bug</span>
<div class="ui modal test">
<form action="FileBug" method="post">
<div class="ui segments">
<br>
<h3 align="center" class="header">Bugzilla Login</h3>
<div class="ui container">
<c:if test="${not empty errorMessage}">
<c:out value="${errorMessage}"/>
</c:if>
</div>
<div class="ui segment">
<div class="ui input">
<input type="text" name="username" placeholder="Bugzilla Username" required>
</div>
</div>
<div class="ui segment">
<div class="ui input">
<input type="password" name="password" placeholder="Bugzilla Password" required>
</div>
</div>
<div class="ui segment">
<br>
<button class="ui blue button" id="login">Login</button>
<br><br>
</div>
</div>
</form>
</div>
</a>
script:-
<script>
$(function(){
$("#test").click(function(){
$(".test").modal('show');
});
$(".test").modal({
closable: true
});
});
</script>
<style>
div.ui.modal{
width: 20%;
top: 45%;
left: 75%;
}
div.ui.input {
width: 100%;
}
button#login{
margin: -20px -50px;
position:relative;
top:50%;
left:53%;
}
div.ui.input input {
display: block;
margin: 0 auto !important;
float: none;
}
</style>