Save and retrieve password in jsp
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Unless you're a full-time trained security professional, you should avoid creating your own security system. Security is too important to be something done as a secondary consideration in today's hostile world. Even if your app does something as simple as trade Pokémon cards, an invader might re-purpose it to launch malware and/or spam.
J2EE/JEE defines a standard container-managed security system. It's built into all major webapp servers, including Tomcat, jetty, Wildfly and the "big name" commercial products. Typically that system has plugin authenticator modules ("Realms") so that you can keep your userids and passwords wherever and however you want to. For example, Tomcat's MemoryRealm uses a simple XML data file format. The JDBC Realm uses SQL databases, and the JNDI Realm can use LDAP servers such as Microsoft's Active directory.
A lot of J2EE books use a user-written login system for code examples. I wish they wouldn't do that. The Internet is polluted enough.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik Dey wrote:Ideally you should not be having any java code in jsp, it should be handled by servlet. As far as appending to file is concerned, you have to create the FileWriter object in append mode.
Inside .jsp file i had written the above code. So instead of that code what should i use means how to handle it by servlet? Please tell me how to.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
public class ExampleHttpServlet extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException){
}
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException){
}
}
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
, I am using tomcat webserver. So how should i use the database. Is there anything to configure to use the database?Tomcat's MemoryRealm uses a simple XML data file format
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik Dey wrote:For simple jdbc connectivity you don't need any specific configuration in server. It's the jdbc api that's connect to database. Are you ok with jdbc connectivity.
I am ok with this. But as for now i am doing with text file. I also want to know how to verify username and password. If user name already exist in text file i don't want to append. Is it possible to do the user validation using text file.Can you please tell me is it possible to do?
Also I would like to know about jdbc connectivity. Please guide me.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
how to connect to database, how to execute sqls after connecting to db etc.
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik Dey wrote:Of course possible, what you are doing with the present code is writing to the file. For validation purpose what you have to do is read from the file. For JDBC you should read about this, and try to write a simple java application (not web) to learn the basic stuffs like
how to connect to database, how to execute sqls after connecting to db etc.
The following is the code which i am trying to read contents.
Still the same name appends in the text file. can you please tell me what i am doing wrong. And with above code how to validate please help me.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
The above part of the code will always append to the file, as you are opening it in write mode.
For validation part you only need the 2nd part with some minor logical changes
Ideally you should have two different pages, one for user registration, that will call the writing code, and the other page should be a validation page that will call the reading code.
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Is it Possible to avoid appending the same username?
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Like drupal, wordpress.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
For JDBC you should read about this, and try to write a simple java application (not web) to learn the basic stuffs like
how to connect to database, how to execute sqls after connecting to db etc.
I will start to learn about jdbc connectivity, to executte queries too. As i am creating web applicationWhat should i start to read and know about jdbc connectivity in eclipse.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
INFO: Server startup in 377 ms
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.candidjava.LoginController.doPost(LoginController.java:32)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
This is my code for creating datebase
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Also whenever i am running my app its tring to create db again and again. how to avoid this. Can't create database 'LoginDetails'; database exists please help me.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
In the if condition I am trying to give alert message. But nothig is getting displayed. Please tell me where i am wrong
In the else
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Swastik
| Normally trees don't drive trucks. Does this tiny ad have a license? Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |








