| | |
Design idea?
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2007
Posts: 11
Reputation:
Solved Threads: 0
Q: Create a JSP based page wherein by clicking the add button the user details should be added to the database and clicking the delete button should delete the particular user details from the database. I am new to JSP so dont have much idea how to proceed? Do we need to use JDBC or we can create & manipulate a database using JSP?
Please help me to start....
Please help me to start....
•
•
Join Date: Aug 2008
Posts: 16
Reputation:
Solved Threads: 1
basically what you need to do is simply just like you are building any desktop application. you need to have a connection with your database which in this case is using JDBC since you are developing a web using JSP. Once you have created the connection between you web and database you can start do any kind of action to do the interaction between your web and database. here's a basic login example to give you some basic clue.
your_login_form.jsp
doLogin.jsp
your_login_form.jsp
html Syntax (Toggle Plain Text)
<table width="982" height="543" border="0" align="center" class="table"> <form id="login" name="login" method="post" action="doLogin.jsp"> <tr> <td align="center" valign="middle"><table width="212" height="286" border="0"> <tr> <td height="135" align="left" valign="bottom"><input name="username" type="text" class="field_bg" maxlength="15"/></td> </tr> <tr> <td height="65" align="left" valign="bottom"><input name="password" type="password" class="field_bg" maxlength="15"/></td> </tr> <tr> <td height="73" align="right" valign="bottom"><input type="submit" name="Submit" value="" class="button_bg" /></td> </tr> </table></td> </tr> </form> </table>
doLogin.jsp
jsp Syntax (Toggle Plain Text)
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <% String name = request.getParameter("Username"); String pass = request.getParameter("Password"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=" + application.getRealPath("WEB-INF/db.mdb")); Statement stmt = con.createStatement(1004,1008) ; ResultSet rs = stmt.executeQuery("Select * from MsUser where username='" + name + "' and password ='" + pass + "'"); Boolean exist = rs.first(); if(exist == true) { session.setAttribute("__IN",rs.getString("username")); con.close(); response.sendRedirect("index.jsp"); } else out.print("Login Failed"); %>
Last edited by peter_budo; Nov 20th, 2008 at 6:07 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Last edited by peter_budo; Nov 20th, 2008 at 6:11 am.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Need to know how to turn my software idea into a tangible product (Software Development Job Offers)
- Professional web design and programming services (Post your Resume)
- database Design Idea (Database Design)
- computer freezes after 20 min (Windows 95 / 98 / Me)
- Game Programming / Software Design (Computer Science)
- program design (Visual Basic 4 / 5 / 6)
- If anybody needs web design articles (Post your Resume)
- Innotive ideas on existing design (Site Layout and Usability)
Other Threads in the JSP Forum
- Previous Thread: Reading the mail ids from other websites.
- Next Thread: how to authenticate the users without login and password
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






