OK thanks for your example but I tried to do another thing, I removed the debug servlet so the project had only the login servlet; I tried to run the project but, when I clicked on the login button, the page didn't do any action. I don't understand what's happening
On Aug 4, 5:16 pm, Juan Pablo Gardella <gardellajuanpa...@gmail.com> wrote: > I use Spring Security. But if you are doing a sample, make a filter that > process a post. > > Simple Example. > > @Override > public void doFilter(ServletRequest request, ServletResponse response, > FilterChain chain) > throws IOException, ServletException { > logger.info("Entrando en filtro para procesar el login afip"); > > // cast > HttpServletRequest req = (HttpServletRequest) request; > HttpServletResponse resp = (HttpServletResponse) response; > > // login > login(req); > > // redirect to some url > redirectSomeUrl(req, resp); > } > > private void login(HttpServletRequest req) { > // If is a POST login. > if ("POST".equals(req.getMethod())) { > validateData(req); > } > } > > In validate data check info and create/invalidate session. > > Hope helps. > > 2011/8/4 Luca Meloni <lmelon...@gmail.com> > > > > > > > > > OK I read and now I think it's better to use a filter: have you got > > some sites to suggest me with filter examples? I would appreciate it, > > thank you > > > On Aug 4, 4:35 pm, Juan Pablo Gardella <gardellajuanpa...@gmail.com> > > wrote: > > > Its best do the login in a filter. If you do the login in a filter always > > > execute before servlets. > > > > If you want use a servlet to do login and have other servlet with similar > > > url pattern read > > > this< > >http://www.roguewave.com/portals/0/products/hydraexpress/docs/4.6.0/h...>. > > > With filters you can explicity the order of execution, with servlet no > > (is > > > not define in the specification, so is the serlvet container decide, > > > unpredictable). > > > > Juan > > > > 2011/8/4 Luca Meloni <lmelon...@gmail.com> > > > > > I have two servlets in my project: > > > > - The login servlet tooks the username and the password, checks if > > > > user data is correct and eventually returns the name of the related > > > > database; > > > > - The debug servlet for now can only output a string. > > > > In MainEntryPoint I call the login servlet before the debug servlet, > > > > but I get an output that indicates that the debug servlet is called > > > > before the login servlet; this is the code snippet: > > > > > logInService.logIn(userNameTextBox.getText(), > > > > passWordTextBox.getText(), new AsyncCallback<String>() { > > > > > @Override > > > > public void onFailure(Throwable caught) { > > > > Window.alert("Log in failed!"); > > > > } > > > > > @Override > > > > public void onSuccess(String result) { > > > > dataBaseString = result; > > > > } > > > > }); > > > > > deBugService.outPut("2) DataBase: " + > > > > dataBaseString, new AsyncCallback<Void>() { > > > > > public void onFailure(Throwable caught) { > > > > } > > > > > public void onSuccess(Void result) { > > > > } > > > > }); > > > > > And this is the related output: > > > > > 2) DataBase: null > > > > 1) DataBase: dataBaseName > > > > > On Aug 4, 4:00 pm, Juan Pablo Gardella <gardellajuanpa...@gmail.com> > > > > wrote: > > > > > "Is it necessary to include also Hibernate > > > > > Validator?" No exactly hibernate validator, some jsr303 > > implementation. I > > > > > think is necesary. > > > > > > "I tried to run again the project but the servlets were not > > > > > executed in the correct order" > > > > > > I'm blind. Can you explain a little more your problem? > > > > > > Juan > > > > > > 2011/8/4 Apocalypto <lmelon...@gmail.com> > > > > > > > Thanks for the reply, I included "validation-api-1.0.0.GA.jar" and > > > > > > "validation-api-1.0.0.GA-sources.jar" to project libraries and the > > > > > > errors were solved. Is it necessary to include also Hibernate > > > > > > Validator? I tried to run again the project but the servlets were > > not > > > > > > executed in the correct order > > > > > > > On Aug 4, 1:48 pm, Juan Pablo Gardella < > > gardellajuanpa...@gmail.com> > > > > > > wrote: > > > > > > > Its a classpath issue: > > > > > > > > [ERROR] Line 97: ConstraintViolation cannot be resolved > > to a > > > > > > > type > > > > > > > > Add the javax.validation > > > > > > > jar< > > >http://mvnrepository.com/artifact/javax.validation/validation-api/1.0.. > > > > .> > > > > > > > (jsr303) > > > > > > > and some implementation< > > >http://stackoverflow.com/questions/1384968/is-there-an-implementation.. > > > > .> > > > > > > > . > > > > > > > > Juan > > > > > > > > 2011/8/3 Apocalypto <lmelon...@gmail.com> > > > > > > > > > Hello GWT world, I'm a student who is trying to learn how to > > > > develop > > > > > > > > with GWT framework. I already know well Java language but I'm > > stuck > > > > > > > > with my first application: it's a simple log in interface which > > > > stores > > > > > > > > user data into cookies, but I can't understand why it doesn't > > work > > > > > > > > properly. > > > > > > > > > MainEntryPoint > > > > > > > > > private GWTLogInServiceAsync logInService = > > > > > > > > GWT.create(GWTLogInService.class); > > > > > > > > private GWTDeBugServiceAsync deBugService = > > > > > > > > GWT.create(GWTDeBugService.class); > > > > > > > > private String dataBaseString; > > > > > > > > ... > > > > > > > > logInButton.addClickHandler(new ClickHandler() { > > > > > > > > > public void onClick(ClickEvent event) { > > > > > > > > dataBaseString = null; > > > logInService.logIn(userNameTextBox.getText(), > > > > > > > > passWordTextBox.getText(), new AsyncCallback<String>() { > > > > > > > > > @Override > > > > > > > > public void onFailure(Throwable caught) > > { > > > > > > > > Window.alert("Log in failed!"); > > > > > > > > } > > > > > > > > > @Override > > > > > > > > public void onSuccess(String result) { > > > > > > > > dataBaseString = result; > > > > > > > > } > > > > > > > > }); > > > > > > > > > deBugService.outPut("2) DataBase: " + > > > > > > > > dataBaseString, new AsyncCallback<Void>() { > > > > > > > > > public void onFailure(Throwable caught) > > { > > > > > > > > } > > > > > > > > > public void onSuccess(Void result) { > > > > > > > > } > > > > > > > > }); > > > > > > > > > if (dataBaseString != null) { > > > > > > > > logIn(userNameTextBox.getText(), > > > > > > > > dataBaseString); > > > > > > > > } > > > > > > > > } > > > > > > > > }); > > > > > > > > ... > > > > > > > > private void logIn(String userName, String dataBase) { > > > > > > > > Cookies.setCookie("userName", userName); > > > > > > > > Cookies.setCookie("dataBase", dataBase); > > > > > > > > > Location.reload(); > > > > > > > > } > > > > > > > > > GWTLogInServiceImpl > > > > > > > > > public String logIn(String userName, String passWord) { > > > > > > > > String dataBase = null; > > > > > > > > > try { > > > > > > > > Class.forName("org.postgresql.Driver"); > > > > > > > > > Connection connection = > > > DriverManager.getConnection("jdbc:postgresql://localhost:5432/User > > > > > > > > DataBase", postGreSQLUserName, postGreSQLPassWord); > > > > > > > > > String query = "SELECT \"DataBase\" FROM \"User\" > > WHERE > > > > > > > > \"Name\" = '" + userName + "' AND \"PassWord\" = '" + passWord > > + > > > > "'"; > > > > > > > > > ResultSet resultSet = > > > > > > > > connection.createStatement().executeQuery(query); > > > > > > > > > if (resultSet.next()) { > > > > > > > > dataBase = resultSet.getString("DataBase"); > > > > > > > > } > > > > > > > > } catch (Exception exception) { > > > > > > > > exception.printStackTrace(); > > > > > > > > } > > > > > > > > > System.out.println("1) DataBase: " + dataBase); > > > > > > > > > return dataBase; > > > > > > > > } > > > > > > > > > GWTDeBugServiceImpl > > > > > > > > > public void outPut(String string) { > > > > > > > > System.out.println(string); > > > > > > > > } > > > > > > > > > I get the following output: > > > > > > > > 2) DataBase: null > > > > > > > > 1) DataBase: dataBaseName > > > > > > > > > Why does it execute GWTDeBugService before GWTLogInService? I'm > > > > using > > > > > > > > NetBeans 6.9.1 with the latest GWT framework and GWT4NB plugin. > > > > > > > > In addition, during compilation I get the following errors: > > > > > > > > Validating newly compiled units > > > > > > > > [ERROR] Errors in > > 'jar:file:/{projectFolder}/lib/GWT2.3.0/gwt- > > > > > > > > user.jar!/com/google/gwt/editor/client/EditorDriver.java' > > > > > > > > [ERROR] Line 20: The import > > > > > > > > javax.validation.ConstraintViolation cannot be resolved > > > > > > > > [ERROR] Line 97: ConstraintViolation cannot be resolved > > to > > > > a > > > > > > > > type > > > > > > > > [ERROR] Errors in > > 'jar:file:/{projectFolder}/lib/GWT2.3.0/gwt- > > > > > > > > user.jar!/com/google/gwt/editor/client/impl/ > > > > > > > > AbstractSimpleBeanEditorDriver.java' > > > > > > > > [ERROR] Line 28: Name clash: The method > > > > > > > > setConstraintViolations(Iterable<ConstraintViolation<?>>) of > > type > > > > > > > > BaseEditorDriver<T,E> has the same erasure as > > > > > > > > setConstraintViolations(Iterable<ConstraintViolation<?>>) of > > type > > > > > > > > EditorDriver<T> but does not override it > > > > > > > > [ERROR] Errors in > > 'jar:file:/{projectFolder}/lib/GWT2.3.0/gwt- > > > user.jar!/com/google/gwt/editor/client/impl/BaseEditorDriver.java' > > > > > > > > [ERROR] Line 31: The > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.