im doing a simple login page:
<div class="form-signin" role="form" ng-controller="loginController">
<div class="center-block" ng-repeat="erro in erros">
<span class="error">{{erro.message}}</span>
</div>
<h2 class="form-signin-heading">Identifique-se</h2>
<input type="email" class="form-control" placeholder="Endereço de Email" ng-model="usuario.email" autofocus>
<input type="password" class="form-control" placeholder="Senha" ng-model="usuario.senha" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Lembrar Dados
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" ng-click="Logar()" type="submit">Entrar</button>
</div>
it do a POST to "/MyService/Example/Login" javaee backend using the usuario.email and usuario.senha fields, i can read and return true or not normally, but my doubt is, how can i implement a Token? im already generating a token using the UUID random + useremail + creation time. I have to send it with the JSON? i have to do a request.addHeader in the backend and add the token there? and how can i implement a kind of service that EVERY page it do a "requestLogin", so when users login for first time it send a blank token-cookie, after login server return the cookie, user store in the cookie, and for every page/request it send the token-cookie back and i can verify if its authentic, if not, send false and than angular return to the login page?!
i mean, im not asking for code, i saw some tutorials about token + angular, but was "simple" to understand explaining why and how to use the thing =\
Related
I'm using thymeleaf for my web application. There is a problem about save and update functions. When I want to save a campaign from ui, the campaign object fields come null to rest controller class. This problem just occure in weblogic server(12.1.3). When I try it in tomcat server, do not occure any error.
my edit and create page as follow. There are a few fields for campaign, but I wrote some of them in here. Bytheway, I am sure that all fields ready in the html page. Some of them hidden, some of them visible.
<div class="row">
<form name="Form" class="col s8 offset-s2" id="upload-file-form"
enctype="multipart/form-data" th:object="${campaign}"
th:action="#{/admin/getCampaign}" onsubmit="return validateForm()"
method="post">
<div class="row">
<input type="hidden" th:field="*{id}"/>
<input type="hidden" th:field="*{version}"/>
</div>
<div class="row">
<div class="input-field">
<input id="brandname" type="text" class="validate" th:field="*{brandname}">
<label for="brandname">Brand Name</label>
</div>
</div>
</form>
</div>
#RequestMapping(value = "admin/getCampaign", method = RequestMethod.POST)
public String uploadingPost(#RequestParam("uploadingFiles") MultipartFile[] uploadingFiles,
#RequestParam("uploadingFiles1") MultipartFile[] uploadingFiles1,
#RequestParam("uploadingFiles2") MultipartFile[] uploadingFiles2,
#RequestParam("uploadingFiles3") MultipartFile[] uploadingFiles3,
Campaign campaign) throws IOException {
/** this is my controller method for save or update.
*/
}
in weblogic server campaign parameter fields come null (as a new object), but in tomcat server, everything is normal.
UPDATE:
I changed my ui fields to value like this post. But the problem continue.
<input type="hidden" th:value="*{id}"/>
Your form enctype is "multipart/form-data".
So you must add spring.http.encoding.enabled=false to application.properties.
It should be <input type="hidden" th:field="*{id}"/>not th:value
<center>
<form class="form-horizontal" action="${pageContext.servletContext.contextPath}/LargeLandmarkListGet" method="post">
<div class="form-group">
<label class="control-label col-sm-2" for="SLLRID">SLLRID:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="SLLRID" placeholder="Enter SLLRID...">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
</center>
That is the particular definition of the action in the JSP.
String SLLRID = request.getParameter("SLLRID");
This is how I am trying to get it in the servlet, within the doPost method. However, SLLRID is always null. I've tried everything I can think of but I cannot get it to return the inputted value. However, if I hardcode the value, everything works perfectly, so I think there is something wrong when communicating between the JSP and the servlet.
What I Have Tried:
Changing the name in for in the label definition, so that id and for are named differently
Adding an id value to the button
Hardcoding the value to verify the servlet
Trying a get rather than a post (though that seemed wildly inappropriate)
Testing other servlets with the same JSP (this worked, though not with this particular submission id)
Ensuring that everything that needed entries in web.xml had said entries made
The form sends the data based on the name attribute. So instead put: <input type="text" class="form-control" id="SLLRID" name="SLLRID" placeholder="Enter SLLRID...">
I am having a hard time trying to figure out the correct process for automating login for the following website: http://abelhas.pt
I have used Firefox's HttpFox plugin to discover the login form and action page url, in the generated HTML code and have found out that to perform login, I will need to post the following parameters:
Login=theLogin
Password=thePassword
Redirect=True
RedirectUrl=
RememberMe=false
FileId=0
The url to which the parameters are being passed when the user presses the submit button, is the following: "/action/login/login" (which is the one shown on the "action" attribute of the html element)
However, when generating and posting it using the following URL:
http://abelhas.pt/action/login/login?Login=theLogin&Password=thePassword&Redirect=True&RedirectUrl=&RememberMe=false&FileId=0
(Please note that the the values of "theLogin" and "thePassword" should be replaced by a valid login and password)
I am always getting "http://abelhas.pt/Error404.aspx", meaning that the following webpage was not found...
In the past, I have already been able to successfully automate logging-in in websites such as Google, filefactory, zippyshare, Imageshack, etc..however this one seems to be playing tricks on me...
Can someone help me understanding what is happening or what am I doing wrong?
Many thanks guys!
Gizmo
In my vaadin application i want to redirect to a website with automatic log in.
Now the issue is am unable to logIn through my java code which refers from
http://www.mkyong.com/java/how-to-automate-login-a-website-java-example/
Am also getting response code: 200, and unable to make use of response.
Following is the code snippet of the website to which i want to automate login
<form action="login.php" method="post" id="clientLogin">
<input type="hidden" name="__CSRFToken__" value="eac035fe0a1a64a9945e0ce798a44a52ca040b5c" /><div style="display:table-row">
<div class="login-box">
<strong></strong>
<div>
<input id="username" placeholder="Email or Username" type="text" name="luser" size="30" value="">
</div>
<div>
<input id="passwd" placeholder="Password" type="password" name="lpasswd" size="30" value=""></td>
</div>
<p>
<input class="btn" type="submit" value="Sign In">
</p>
</div>
<div style="display:table-cell;padding: 15px;vertical-align:top">
<div>
<!--<b>I'm an agent</b> —
sign in here
-->
</div>
</div>
</div>
</form>
I am writing application on playframework. I have a search form and I want to send POST request and be able to accept it in my controller, how this is possible?
There Many samples for it, First Add a method login in your Application (or whatever) controller.
Lets assume your posting login details for your controller.
public static void login(String userCode,String password){
User loginUser = User.find("byUserCodeAndPassword",userCode,password).first();
if(loginUser == null){
flash.put("username",userCode);
flash.error("Invalid Credentials");
index();
}
else{
Cache.set(session.getId(),loginUser,"20mn");
Home.Home();
}
}
In your conf/routes file add
POST / Application.login
Assuming you have a index.html in your app/views/Application folder.
From the Html Page:
<div id="login">
#{form #login(), id:'formLogin'}
<p class="field">
<label>User Code:</label>
<input type="text" name="userCode" size="19" value="${flash.userCode}" required>
</p>
<p class="field">
<label>Password:</label>
<input type="password" name="password" size="19" required>
</p>
<p class="buttons">
<input type="submit" value="Login">
</p>
#{/form}
in my jsp, when i navigate through tab key it skips my Save and Reset button. and move to next component in my page. even though i have not used tabindex in my jsp files. please suggest what could be the reason. thanks
code is like:
<div>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}"/>
<input type="submit" class="button" name="_eventId_search" value="Search"/>
<span class="save_button_common" onClick="submitForm('save')">Save</span>
<span class="reset_button_common" onClick="submitForm('reset')">Reset</span>
</div>
May be because it is not input type , you can explicitly try setting tabIndex
Try:
<div>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}"/>
<input type="submit" class="button" name="_eventId_search" value="Search"/>
<input type="button" class="save_button_common" onClick="submitForm('save')">Save</input>
<input type="button" class="reset_button_common" onClick="submitForm('reset')">Reset></input>
</div>
Note if it's a form you need input type="button" rather than just using <button> which you can otherwise just for straight links that don't submit a form. This is particularly relevant with Internet Explorer that treats the button tag somewhat differently to other browsers (submitting the "value=" rather than the enclosed text or something like that)