Results 1 to 2 of 2
Thread: jsp-mysql
- 02-09-2013, 03:43 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 16
- Rep Power
- 0
jsp-mysql
hi friends,
i am new to jsp and my doubt may seem very funny to you all but without clarifying it i can't move on with my project .
i wrote a simple jsp program which accepts the name and password values from the user and compares them with the values in the database and displays 'correct' if they match and 'wrong' if they doesn't match.
i am not using any IDE. i am writing the programs in notepad files and executing them
here's the html page that reads values from the user
here's the jsp programJava Code:<html> <body> <form action="check.jsp" method=get> uname:<input type="text" name="name"><br> pass: <input type="password" name="pass"><br> <input type="submit" value="submit"> </form> </body> </html>
here's the html page that displays the message correctJava Code:<%@ page import="java.sql.*"%> <%@ page import="java.io.*"%> <% String name=request.getParameter("name"); String pass=request.getParameter("pass"); Connection con = null; ResultSet rs=null; Statement stmt; String connectionURL = "jdbc:mysql://localhost:3306/pms";; try{ Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection(connectionURL, "root", "root"); stmt=con.createStatement(); rs = stmt.executeQuery("select * from login where name='"+name+"' and password='"+pass+"'"); if(rs.next()) { response.sendRedirect("profile.html"); } else { response.sendRedirect("index1.html"); } } catch(Exception e){ System.out.println(e); } %>
here's the html page that displays the messageJava Code:<html> <body> correct </body> </html>
here's the web.xml fileJava Code:<html> <body> wrong </body> </html>
when i enter name and password fields and press enter, a blank page is displayed and i cant get the output. the address bar contains "http://localhost:8080/pms/check.jsp?name=abc&pass=abc"Java Code:<WEB-APP> <WELCOME-FILE-LIST> <WELCOME-FILE> homepage.html </WELCOME-FILE> </WELCOME-FILE-LIST> </WEB-APP>
what is the problem with my program ?
pls anyone help me guys...
its important for meLast edited by pardhu; 02-09-2013 at 04:03 PM.
- 02-11-2013, 11:37 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: jsp-mysql
This is not the sort of thing a JSP is for.
JSPs display the results of processing done by a servlet.
So your above should be in a servlet, and that should forward to the relevant HTML page.
Servlets are a lot easier to debug.
Anyway, are you sure there is an entry in your database for username abc and password abc?Please do not ask for code as refusal often offends.
Similar Threads
-
Java DB, MySQL and MySQL Connector/J
By jimihunter007 in forum JDBCReplies: 2Last Post: 07-30-2012, 05:23 AM -
Is this a java issue? JApplet with MySQL access.. can't connect to mySQL
By cplredhartsock in forum Java AppletsReplies: 4Last Post: 03-04-2012, 11:26 PM -
MySQL
By PhQ in forum New To JavaReplies: 6Last Post: 04-03-2010, 12:54 PM -
MySQL/JDBC Mysql query output
By thelinuxguy in forum Advanced JavaReplies: 4Last Post: 02-13-2009, 01:57 AM -
Mysql Help
By Sumendra Maharjan in forum JDBCReplies: 1Last Post: 08-08-2007, 01:19 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks