473,583 Members | 3,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help-How to insert input parameter in DB through Java Bean

11 New Member
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
SimpleBean 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:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>A simple JSP application</title>
  4. <head>
  5. <body>
  6. <form method="get" action="tmp" >
  7. Name: <input type="text" name="user">
  8. Password: <input type="password" name="pass">
  9. <input type="Submit" value="Submit">
  10. </form>
  11. </body>
  12. </html>
LoginServlet.ja va:

Expand|Select|Wrap|Line Numbers
  1. import javax.servlet.*;
  2. import javax.servlet.http.*;
  3. public class LoginServlet extends HttpServlet{
  4. public void doGet(HttpServletRequest request, HttpServletResponse response)
  5. throws ServletException{
  6. try
  7. {
  8. String user=request.getParameter("user");
  9. String pass=request.getParameter("pass");
  11. co.SimpleBean st = new co.SimpleBean();
  13. st.setUserName(user);
  14. st.setPassword(pass);
  17. request.setAttribute("user",st);
  18. request.setAttribute("pass",st);
  19. RequestDispatcher dispatcher1 =request.getRequestDispatcher("submit.jsp");
  20. dispatcher1.forward(request,response);
  21. }
  22. catch(Exception e)
  23. {
  24. e.printStackTrace();
  25. }
  26. }
  27. }
SimpleBean.java :

Expand|Select|Wrap|Line Numbers
  1. package co;
  2. import java.util.*;
  3. import java.io.*;
  4. import javax.servlet.*;
  5. import javax.servlet.http.*;
  6. import java.sql.*;
  7. import java.util.*;
  9. public class SimpleBean {
  11. private String user="";
  12. private String pass="";
  13. private String s="";
  15. public String getUserName() {
  16. return user;
  17. }
  18. public void setUserName(String user) {
  19. this.user = user;
  20. }
  21. public String getPassword() {
  22. return pass;
  23. }
  24. public void setPassword(String pass) {
  25. this.pass = pass;
  26. }
  28. public String getIssueData() //method that create connection with database
  29. {
  30. try
  31. {
  32. System.out.println("Printed*************************************************************");
  33. getUserName();
  34. getPassword();
  36. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  37. System.out.println("Loading....");
  38. Connection con=DriverManager.getConnection("jdbc:odbc:simple");
  39. System.out.println("Connected....");
  40. PreparedStatement st=con.prepareStatement("insert into Table1 values(?,?)");
  41. System.out.println("~~~~~~~~~~~~~~~~~~~~");
  42. String User=getUserName();
  43. st.setString(1,User);
  44. String Password=getPassword();
  45. st.setString(2,Password);
  46.  st.executeUpdate();
  47. System.out.println("Query Executed");
  48.  con.close();
  49.  s=  "Your logging is saved in DB ";
  50. System.out.println("Your logging is saved in DB *****************");
  51. return(s);
  52. }
  53. catch(Exception e)
  54. {
  55. e.printStackTrace();
  56. return "failed";
  57. }
  58. }
  59. }
This is Submit page

Expand|Select|Wrap|Line Numbers
  1. <html><body>
  2. Hello
  3. Student Name: <%= ((co.SimpleBean)request.getAttribute("user")).getUserName() %>
  4. <br>
  5. Password: <%= ((co.SimpleBean)request.getAttribute("pass")).getPassword() %>
  6. <br>
  7. <jsp:useBean id="st" class="co.SimpleBean" scope="request" />
  8. <jsp:getProperty name="st" property="IssueData" />
  9. </body></html>

Expand|Select|Wrap|Line Numbers
  1. <web-app>
  3. <servlet>
  4. <servlet-name>one</servlet-name>
  5. <servlet-class>LoginServlet</servlet-class>
  6. </servlet>
  8. <servlet-mapping>
  9. <servlet-name>one</servlet-name>
  10. <url-pattern>/tmp</url-pattern>
  11. </servlet-mapping>
  13. <jsp-file>issue.jsp</jsp-file>
  14. <jsp-file>submit.jsp</jsp-file>
  15. <url-pattern>*.do</url-pattern>
  17. <welcome-file-list>
  18. <welcome-file>Login.html</welcome-file>
  19. </welcome-file-list>
  21. </web-app>

Please Help me..Thanks.!!!
Oct 18 '08 #1
2 3314
392 Recognized Expert Contributor
It does not look like you are calling the getIssueData() method any where. Since that is where the code is that writes the data to the database if you do not call it the data will never be written.
Oct 20 '08 #2
11 New Member
It does not look like you are calling the getIssueData() method any where. Since that is where the code is that writes the data to the database if you do not call it the data will never be written.
Dear Sir,
Can you write me How that code will be invoke which write in getIssueData().
Please Help me...
Oct 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its last year we got traffic of between 2000 - 2500 unique visitors per day. We are now about to re-launch the site from Sweden and we need to purchase a...
by: Gregory Nans | last post by:
hello, i need some help to 'tree-ify' a string... for example i have strings such as : s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i need))""" and i need to parse them to have a tree representation such as :
by: xunling | last post by:
i have a question about answering ..... this topic is "need help" what do i have to write at te topic line, !after i have klicked the "answer message" button ive tried many possibilities, all dont work "Re:" need help "Re:need help"
by: blah | last post by:
Need python Pro at newtopython@googlegroups.com , if u wanna help, plz reply to that address. We are python beginners. need a real good Python Programmer for Help. TIA!! -- * Posted with NewsLeecher v3.0 Beta 7 * http://www.newsleecher.com/?usenet
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or SQLNET in ORACLE that would allow me to connect to a database on a remote box (either AIX or AS/400)? I have read that DB2 Connect appears to be the...
by: Paul Mendez | last post by:
I really need some help Date Code ConCAT Bal_Fwd NS_Fees Amt_Coll Cur_End_Bal 1/15/2004 KW 11KW2003 $500.00 $250.00 $250.00 2/15/2004 KW 12KW2003 $300.00 $500.00 -$200.00 3/15/2004 KW 1KW2004 ???? $123.00 $584.00 -$461.00 4/15/2001 KW 2KW2004 XXXX $223.00 $484.00 -$261.00...
by: MSDN Account | last post by:
We have web site that used the IIS ResKit tool MSWC.PermissionChecker to check file permissions. The web site has been upgraded and that upgrade included changing the default server side language from VBScript to C# (*.vbs --> *.cs). Does C# have a native method for doing what MSWC.PermissionChecker used to do? If so has anyone gone...
by: Elliot M. Rodriguez | last post by:
I am having a heckuva time debugging this, or determining why my page is behaving this way. I have a search form, that when completed, returns a datagrid. When the user selects a row (normal selectcommand button), i assign some session variables and perform a rediect to a "more information" page. Neither page is using Output Caching. On...
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
by: XML Beginner | last post by:
I have an XML file that contains values that my application needs, so it knows which database to connect to. It also contains a configuration option so that I can specify which node to return values from. For example, the XML file is meant to return the values from node"config2", because the "configoption" node's value is that. I'm...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.