User parameter are not show in database using Servlet and java Bean

Hello Sir,
when I insert the parameter in run time, weblogic server and JSP show that parameter are saved.
Allthough row increment in database but they not show in database.
Here My Code:
login.html:
<html>
<head>
<title>A simple JSP application</title>
<head>
<body>
<form method="get" action="tmp" >
Name: <input type="text" name="user">
Password: <input type="password" name="pass">
<input type="Submit" value="Submit">
</form>
</body>
</html>LoginServlet.java:import javax.servlet.*;
import javax.servlet.http.*;
public class LoginServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException{
try
String user=request.getParameter("user");
String pass=request.getParameter("pass");
co.SimpleBean st = new co.SimpleBean();
st.setuserName(user);
st.setpassword(pass);
request.setAttribute("user",st);
request.setAttribute("pass",st);
RequestDispatcher dispatcher1 =request.getRequestDispatcher("submit.jsp");
dispatcher1.forward(request,response);
catch(Exception e)
e.printStackTrace();
}SimpleBean.java:
package co;
import java.util.*;
import java.io.*;
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 issueData()
try
System.out.println("Printed*************************************************************");
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Connection loaded");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@VijayKumar-PC:1521:XE","SYSTEM","SYSTEM");
System.out.println("Connection created");
PreparedStatement st=con.prepareStatement("insert into vij2 values(?,?)");
System.out.println("~~~~~~~~~~~~~~~~~~~~");
String NAME=getuserName();
st.setString(1,NAME);
String PASSWORD=getpassword();
st.setString(2,PASSWORD);
  st.executeUpdate();
System.out.println("Query Executed");
con.close();
s=  "Your logging is saved in DB ";
System.out.println("Your logging is saved in DB *****************");
return(s);
catch(Exception e)
e.printStackTrace();
return "failed";
}submit.jsp:This is Submit page
<jsp:useBean id="st" class="co.SimpleBean"/>
<jsp:setProperty name="st" property="*" />
<jsp:getProperty name="st" property="userName" /> <br>
<jsp:getProperty name="st" property="password" /> <br>
<% st.issueData();%>
<%
out.println("Ur data is saved in DB");
%>Please Help me.
Thanks.

Ok, this seems to be a long and convoluted path to do absolutely nothing.
You submit the form.
You run a servlet that gets the parameters correctly (good), creates a SimpleBean (good) and then sets this into request attribute space under the names "user" and "pass" - (why?)
You then forward to the jsp: submit.jsp.
Submit.jsp creates a new SimpleBean, and attempts to populate it with <jsp:setProperty>. You then call the issueData method on it.
Your complaint: Rows are being created in the database which have empty string values instead of the parameters you have passed.
So, why are the values blank? Where do you think these values should be coming from?
Looking at SimpleBean we find one mistake - you have mis-named your get/set methods.
To properly follow java beans standards, you should use camel-case for your methods.
Rather than getuserName() the method should be getUserName(). getpassword() should be getPassword() etc etc.
The method getUserName() defines a property "userName" for the bean.
Once that is fixed, lets go to submit.jsp. The <jsp:setProperty> statement will try and set all properties of the bean from the request parameters.
There are no request parameters "userName" or "password" so those values don't get set in the bean, therefore it uses their default value of empty string - "".
There ARE request parameters called "user" and "pass" but because they aren't properties of the bean, they get ignored.
As a result, the values are empty string, and that is exactly what gets inserted into the database.
Ways to fix this
1 - rename your parameters on your form to be "userName" and "password" to match the bean. That way the <jsp:setProperty> tag will populate them properly.
or
2 - Call issueData() method from your servlet after you have created the SimpleBean. Better in my opinion as you then don't have any scriptlet code on a JSP page.
Cheers,
evnafets

Similar Messages

  • Request parameter are not stored in database through Java Bean

    Hi,
    I want to store the request parameter in database through Java Bean.Allthough program are properly run but value are not store in DB.
    Here My code:
    Login.html:<html>
    <head>
    <title>A simple JSP application</title>
    <head>
    <body>
    <form method="get" action="submit.jsp" >
    Name: <input type="text" name="User">
    Password: <input type="password" name="Pass">
    <input type="Submit" value="Submit">
    </form>
    </body>
    </html>SimpleBean.java:
    package co;
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.*;
    public class SimpleBean implements java.io.Serializable{
    private String User="";
    private String Pass="";
    public SimpleBean(){}
    public String getUser() {
    return User;
    public void setUser(String User) {
    this.User = User;
    public String getPass() {
    return Pass;
    public void setPass(String Pass) {
    this.Pass = Pass;
    public void show()
         try
    System.out.println("Printed*************************************************************");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("Loading....");
    Connection con=DriverManager.getConnection("jdbc:odbc:Ex11dump");
    System.out.println("Connected....");
    PreparedStatement st=con.prepareStatement("insert into Table1 values(?,?)");
    System.out.println("~~~~~~~~~~~~~~~~~~~~");
    String User=getUser();
    st.setString(1,User);
    String Pass=getPass();
    st.setString(2,Pass);
    int y= st.executeUpdate();
    System.out.println(y);
    System.out.println("Query Executed");
    con.commit();
    con.close();
    System.out.println("Your logging is saved in DB *****************");
    catch(Exception e)
    e.printStackTrace();
    }submit.jsp:
    <jsp:useBean id="obj" class="co.SimpleBean"/>
    <jsp:setProperty name="obj" property="*" />
    <jsp:getProperty name="obj" property="User" /> <br>
    <jsp:getProperty name="obj" property="Pass" /> <br>
    <% obj.show();%>
    <%
    out.println("Ur data is saved in DB");
    %>Please Help me.
    Thanks.

    The issue is in the naming of your fields.
    Change User -> user and Pass->pass
    Name: <input type="text" name="user">
    Password: <input type="password" name="pass">

  • Could not connect to database using servlet

    Hi,
    i'm using oracle 8.1.5.0.0, tomcat 3.2.1, jdk1.2.2 to build an intranet application. I downloaded the classes12.zip and nls_charset12.zip from the oracle web site and install in the oracle\ora81\jdbc\lib directory.
    when i tried to run the samples code provided by oracle, the program can run properly. but when i tried to run it in my own program using servlet, i got an error as follow:
    java.sql.SQLException IoException:The Network Adapter could not establish a connection.
    i have gone through the codes but could not found any errors that I made and now i'm run out of ideas on the error i get.
    could someone please help me with this problem?
    thank you.
    regards,
    Josephine
    null

    No, the web server requires no configuration. You do need to make sure that the classes12.zip file is in the Tomcat classpath - I believe the Tomcat startup script pulls in all the files in $TOMCAT_HOME/lib, so put the zip file there. I assume you had to change your hostname in the connection URL - what are the connection parameters you used in the Oracle samples? Were these samples Servlets, or command-line programs? Usually when you get the "Network Adapted could not establish a connection" error from the JDBC thin driver, it means that your hostname or port number or SID are wrong,or the database is not up.
    John H.
    null

  • SharePoint lists are not showing in SharePoint designer "Lists and Libraries" section

    Hi , 
    I using sharepoint 2010 and sharepoint designer 2010.
    I created a custom list on the sharepoint , and i trying to open the list through designer, but in sharepoint designer under the "Lists and Libraries" section that created custom list is not showing.
    But when i click on "AllFiles-->Lists -->MyCustomlist " (its present in the root folder's "Lists" folder)
    can anyone help on this.
    regards,
    RK

    Hi,
    According to your description, there is a list appears in “All Files” section but not in "Lists and Libraries" section in SharePoint Designer.
    What if you refresh(F5) the SharePoint Designer in the "Lists and Libraries" section? Will the issue list appears?
    If the list still doesn’t show up, please clear the cache of the SharePoint Designer and reconnect your site for a test.
    About how to clear the cache of SharePoint Designer:
    http://www.c-sharpcorner.com/UploadFile/sagarp/how-to-clear-your-sharepoint-designer-20102013-cache/
    Feel free to reply if there any progress.
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • I was loading photos off my camera and my I photo deleted all my photos, now they are not showing in my I photo and it wont open any photos , why can anyone help

    Does anyone know why my photos have all gone out of my I phots and when I try to open any I have found it wont even show/open them, or return them to my I photo album???
    I was uploading them off my camera's memory stick one worked perfect the next went barmy and deleted all my photos, it said there had been an error but ther was nothing I could do to save them.  How do I retrieve them and how do I make my I photo work again??  Please I have lost over a thousand photos of my brothers wedding.

    What version of iPhoto?

  • Not receiving correct results using to_timestamp and java code

    Using Linux AS3 10.1.0
    When I run the following query via ISQL, I receive results. Executing the same query via a java program returns no results. In the time range, if I change the 16:00:00 to 03:00:00, I get results VIA the JAVA CODE and ISQL. I am not receiving an error message in java or the database. If there is a problem with the java code, why do I get results when I change to 03:00:00?
    Any comments / solutions are much appreciated!
    SELECT (to_char(time_started, 'YYYY-MM-DD HH24:MI:SS')) AS dtg FROM table1 WHERE (time_started between to_timestamp('2006/04/19 16:00:00', 'YYYY/MM/DD HH24:MI:SS') and (to_timestamp('2006/04/21 19:00:00', 'YYYY/MM/DD HH24:MI:SS'))) ORDER BY time_started DESC

    Hi
    1) Is it possible that your Java and iSQL sessions are running in different timezones for some reason (eg because of a login.sql, a login trigger or something similar run by one and not the other, which could have done something like:
    ALTER SESSION SET TIME_ZONE = '-8:00';
    2) Are they TIMESTAMP, TIMESTAMP WITH TIMEZONE, or TIMESTAMP WITH LOCAL TIMEZONE? Given that you are only working down to seconds, would DATE datatype be simpler?
    3) Check the TIME_STARTED values returned and make sure they are what you expect
    4) double check that you really do have identical SQL in both cases, and that you haven't accidentally changed one of them
    HTH
    Regards Nigel

  • Parameter values are not showing in in the Organization Parameter form

    We have done a setup for an Inventory Organization.
    Everything was working fine.
    Values were showing everywhere.
    We have lot of transactions done in the org also.
    But suddenly yesterday when I was trying to open the Organization Parameter form for that specific organization, the form came up as blank and in the bottom the error is Query caused no records.
    I have checked data is there in the base table mtl_parameters.
    Value is coming for other organizations. Only one specific organization is having this issue.
    Even in Examine, I have taken the last query run on that form and ran the same in back end database, I can see all values are there in the database.
    But in frontend screen the values are not showing. even organization code also not showing.
    Navigation is: Inv Super user --> Setup --> Organization --> Parameter

    Have you checked Organization Access to ensure that no one restricted that org?
    Or shipping grants and roles?
    I think there are quite a few places that you can restrict access.

  • Few users are not showing up in Corporate directory

    We have few users at a repote site who are not showing up in Corporate directory. they have UDP profile and they are logged in . i ahve compared the configration with other user of the same site who is showing up in corporate directory and config seems fine
    the User is LDAP integrated in CUCM  and not a local user
    the corporate directory is activated as default  parameter for entire cluster
    Please help if we have any further things to be checked ?

    There was a similar issue a couple weeks ago here
    https://supportforums.cisco.com/discussion/12343101/how-refresh-corporate-directory-cucm-91
    Did you check if the users are not listed if you are registered at the subscriber?
    this was the solution in that mentioned post:
    "worked with cisco we found that the issue only occurs when the phones are registered to the subscriber server...when the phone is registered to the publisher, the directory shows the current information. this indicates and issue with the database replication between the 2 servers.
    the databases have been reset and are replication is resyncing...this will take a couple of hours..."
    Eike

  • Printers are not showing up anymore when user want to select a printer

    I was looking for a Basis forum but couldn't find it. So, I guess this is the best forum where I can post my question.
    Our end users used to be able to select printers but now all printers are not showing up anymore in their output device list. The only printer shown is LOCL.
    This problem just happened from one day to another and now nobody can select printers. The just can print to their LOCL printer
    Any idea or suggestion?
    Marco

    Hi
    Try to check if something is changed in the user profile, try to see the authorization S_SPO_DEV
    Max

  • I tried using the Filmstrip Theme for a podcast but when  imported my Powerpoint slides as photos into iMovie they are not showing up in the project?? How can  fix this??

    I tried using the Filmstrip Theme to make a podcast and when I tried importing my Powerpoint slides as photos they are not showing up in the podcast, they are showing up as black or blank, how can I fix this??

    This may help:
    How to add a Powerpoint presentation to iMovie:
    http://www.wikihow.com/Add-a-PowerPoint-to-iMovie

  • Some videos are not showing in Apple TV playlist after upgrade to 6.0.  Can play on Macbook itunes and using airplay to Apple TV.  Anybody else have this issue?

    Some videos are not showing in my Apple TV playlists after upgrade to 6.0.  They were there prior to upgrade and I can play on Macbook itunes and also using using airplay to Apple TV.  Anybody else have this issue?

    Ok, so I'll try again.  Thank you for the idea of looking in Home Videos, which is where all my "lost" videos are listed.
    Is there a way to get them to display under their appropriate genre in the Movie section, which is where they all were listed prior to the os6 update?  It does me no good to have hundreds of movies categorized in iTunes via a genre only to have them appear in Home Videos on ATV.  These are not "home movies." They are legit mp4 movies that worked great under v5.

  • I am using illustrator CC there are not showing scale size pointer in any object?

    I am using illustrator CC there are not showing scale size pointer in any object? Anyone tell me why it was does it? And how i can come again on that position?

    Or maybe Cmd(Ctrl)-U which is the toggle for Smart Guides?

  • Images and graphics are not showing in certain emails when using Firefox. They show in Google Chrome.

    Certain emails from f.chtah.com(image info) are not showing graphic or image content. This happens in both gmail and hotmail. If opened in Google Chrome, they show up.
    I had my computer wiped clean last week and everything was showing up ok again until this morning. The same emails are having the problem that was going on for the previous month.
    I make sure that all updates are installed.

    I figured it out. Clear your cookies. The company that hosts the images and the stylesheets updated their domain name- i figured this out in Chrome, it was showing a different URL for the css- http://ebm.cheetahmail.com
    After all the cookies (Privacy Tab in preferences) and reloading the pages the images and stylesheets started working again.
    I hope this helps other folks.

  • Text fields populated from lov mapping are not saved to database

    Hi Everyone,
    I'm having a wierd problem. My requirement is to autopopulate two text fields field 2 and field 3 when a value is selected from lov in field1 and save all the values to database on click of a submit button.
    Using lov mapping i'm able to populate field 2 and field 3 with corresponding values based on the value selected in field1. And also field2 and field3 should be in the readonly mode so that user cannot change the value.
    So to make the fields readonly i have changed the property of readonly to true for field2 and field3. But if I change the readonly property, the values for field2 and field3 are not being saved to database.
    The values are getting saved to database only when readonly = true for messageTextInput item type or if the item type is a form value.
    I also tried disable = true, which also didnt work.
    I tried to debug by writing some sop statements in PFR, but these statements also returned null for pageContext.getParameter("field2") etc;
    Can anyone please tell me how to solve this problem?
    Thanks
    Sunny

    Hi Gyan,
    I forgot to mention that , I also tried messageStyledText. Which also didn't work. I wanted to use vo.setAttribute as my last option, but i wanted to understand why the values are not saved to database when the text item is showing the values on the page.
    Thanks
    Sunny

  • Direct Path Read waits are not showing in Elapsed time

    Hi,
    I'm having a question regarding interpretation of a SQL trace file. I'm on Oracle 11.2.0.1 HP/UX 64 bit.
    Following is only the overall result of the trace (it is quite big).
    My question is about the Direct Path Read waits which are totallizing 268s of wait but are not showing in the fetch elapsed time (49.58s) and are not showing anywhere in the trace except in the overall result.
    I do not understand why it is not part of the Elapsed time...
    For info, the trace is for the specific session that was performing all the required queries to display an online report. The database is accessed by the Java application using Hybernate.
    The trace was obtained by the following SQL:
    exec sys.dbms_monitor.serv_mod_act_trace_enable(service_name=>'SYS$USERS',waits=>true,binds=>true);Then I query the sessions to find the one created by the application.
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       36      0.43       0.51          0          5          0           0
    Execute     62      0.01       0.01          0          0          0           0
    Fetch      579      4.01      49.06       3027     153553          0        5516
    total      677      4.45      49.58       3027     153558          0        5516
    Misses in library cache during parse: 29
    Misses in library cache during execute: 2
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                   32754        0.00          0.03
      SQL*Net message from client                 32753        2.33        232.01
      Disk file operations I/O                      179        0.00          0.02
      db file sequential read                      2979        0.54         45.72
      SQL*Net more data to client                133563        0.04          5.30
      direct path read                            34840        0.94        268.21
      SQL*Net more data from client                1075        0.00          0.02
      db file scattered read                          6        0.03          0.11
      asynch descriptor resize                       52        0.00          0.00
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       25      0.00       0.02          0          0          0           0
    Execute     58      0.05       0.04          0          0          0           0
    Fetch      126      0.00       0.04          4        161          0         123
    total      209      0.05       0.11          4        161          0         123
    Misses in library cache during parse: 3
    Misses in library cache during execute: 3
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      Disk file operations I/O                        1        0.00          0.00
      db file sequential read                         4        0.01          0.03
      asynch descriptor resize                        1        0.00          0.00
       37  user  SQL statements in session.
       57  internal SQL statements in session.
       94  SQL statements in session.
    Trace file: oxd1ta00_ora_16542.trc
    Trace file compatibility: 11.1.0.7
    Sort options: default
           1  session in tracefile.
          37  user  SQL statements in trace file.
          57  internal SQL statements in trace file.
          94  SQL statements in trace file.
          57  unique SQL statements in trace file.
      241517  lines in trace file.
         568  elapsed seconds in trace file.Thanks
    Christophe

    Christophe Lize wrote:
    Closing this thread even if it's not answered...Sorry, I don't have time to test this myself now, but you shouldn't mark this thread as answered if it is not, because other people might find it and think they find an answer if they have a similar question.
    I suggest you try the following to narrow down things:
    1. Open the RAW trace file and check the cursor numbers of the "direct path reads" - check if you can find any references for those cursor numbers manually. The cursor numbers are those numbers behind the WAIT #<xx>, and you can check if you find any other entry unequal to WAIT #<xx> with the same #<xx>, for example EXEC #<xx> or FETCH #<xx>
    A short primer on how to interpret the raw trace file can also be found in MOS document 39817.1
    2. Run the RAW trace file through alternative free trace file analyzers like SQLDeveloper (yes it can process raw trace files), OraSRP or Christian Antognini's TVD$XTAT. If you have My Oracle Support access you can also try Oracle's own extended Trace Analyzer (TRCA / TRCANLZR). See MOS Note 224270.1
    Check if these tools tell you more about your specific wait event and oddities with the trace file in general.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    Co-author of the "OakTable Expert Oracle Practices" book:
    http://www.apress.com/book/view/1430226684
    http://www.amazon.com/Expert-Oracle-Practices-Database-Administration/dp/1430226684

Maybe you are looking for

  • SSO between SAP Portal 7.3 and Ruby on Rails

    Hello Everyone, We are planning to integrate SAP Portal 7.3 and a RoR application and I am wondering If someone can share some experience (If you have any of course) on how to establish SSO between SAP Portal and RoR. The SAP Portal will act as servi

  • Acrobat Back Button link

    Hi- Does anyone know how to create a button within a PDF document that returns you to the previous slide/page? ie: I am on page 3, and I click a menu link that takes me to page 10... I want to go back to page 3 by pressing a 'back' button on the imag

  • Is it possible to batch auto-sync?

    If this isn't possible yet, I'm sure it is only a matter of time. I would like final cut pro to be able to analyse and associate dual system recorded audio and video in a batch rathet than the process nesecarily having to start with me telling it "Th

  • Multiple simultaneous height change

    I have a collection of objects in a row, some of which have their heights set to "Expand to fit".  When one object expands to fit, it sticks out from the row and looks bad, so I want the heights of all the objects to expand to match height of the lar

  • Determination matrix for Org Structure

    Hi, The Org structure determination is a very critical step in setting up the ECC system. Is there a tool / standard questionnaire that can be used to create a determination matrix so that the org structure can be designed based on the requirements c