This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to insert input parameter in database through Java Bean  RSS feed

Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sir,
I have a simple Issue but It is not resolve by me i.e input parameter
are not store in Ms-Access.
I store the input parameter through Standard Action <jsp:useBean>.
jsp:useBean call a property IssueData. this property exist in�s a Java Bean) which create a connection from DB and insert the data.

At run time servlet and server also show that loggging are saved in DB.
But when I open the table in Access. Its empty.
Ms-Access have two fields- User, Password both are text type.
Please review these code:
<title>A simple JSP application</title>
<form method="get" action="tmp" >
Name: <input type="text" name="user">
Password: <input type="password" name="pass">
<input type="Submit" value="Submit">
import javax.servlet.*;
import javax.servlet.http.*;
public class LoginServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException{
String user=request.getParameter("user");
String pass=request.getParameter("pass");

co.SimpleBean st = new co.SimpleBean();


RequestDispatcher dispatcher1 =request.getRequestDispatcher("submit.jsp");
catch(Exception e)
package co;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;

public class SimpleBean {

private String user="";
private String pass="";
private String s="";

public String getUserName() {
return user;
public void setUserName(String user) {
this.user = user;
public String getPassword() {
return pass;
public void setPassword(String pass) {
this.pass = pass;

public String getIssueData() //method that create connection with database

Connection con=DriverManager.getConnection("jdbcdbc:simple");
PreparedStatement st=con.prepareStatement("insert into Table1 values(?,?)");
String User=getUserName();
String Password=getPassword();
System.out.println("Query Executed");
s= "Your logging is saved in DB ";
System.out.println("Your logging is saved in DB *****************");
catch(Exception e)
return "failed";

This is Submit page

Student Name: <%= ((co.SimpleBean)request.getAttribute("user")).getUserName() %>
Password: <%= ((co.SimpleBean)request.getAttribute("pass")).getPassword() %>
<jsp:useBean id="st" class="co.SimpleBean" scope="request" />
<jsp:getProperty name="st" property="IssueData" />







I think property value of Java Bean are mismatching.
Please Help me..Thanks.!!!
Author and ninkuma
Posts: 66427
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check your private messages for an important administrative matter.

Also, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you should reference
your getUser() and getPassword()
in the been with this.getUser()
and this.getPassword. Not sure
if the syntax is correct as my
mind is wrapped around PHP right
now. I am pretty sure that
is your problem.

use System.out.println()
to print to the stdOut log located
in the log folder in your Tomcat
installation directory. If you are
using Tomcat that is. This way you can
check within the been if the methods
getPass()and getUsr() are returning
anything before you continue processing
code in the servlet.
[ November 28, 2008: Message edited by: Shawny Starky ]
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest hard-coding your "user" and "pass" variables in the SimpleBean class to some default values and see it these default values get written to the database. If yes, then there is something wrong with your logic and you are hitting the database before setting "user" and "pass". If no, then your database code needs fixing.

that's more of troubleshooting than a resolution

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!