Database access JSP page

I am currently writing a JSP program to add/modify/delete projects. If the user wants to add or modify then I show textboxes or select inputs for the inputs and if it's delete, I just display the text. In order to populate the select inputs, I need to query separate tables from a database. Now here's the question...What is the best way to populate them?
Another question I have concerns if the user is modifying the project. I want the select box to have the item they chose previously to be selected. How would I do this without having to talk to the database too much?
Chris

I think you should put the two fields into one table,then you can query each field based on the user' information passed from JSP pages.
The second question is eary.You can use "javascript" to locate the selection to the item which user has chosed previously,and query the selection values from database.

Similar Messages

  • Suggest me the best practise for accesing database by JSP page

    Hi,
    Can you please suggest me the best practises to connect to database through JSP page.
    I am using the Struts-Portlet environment. And I have to display some contents from the database to the jsp page(view.jsp).
    Please suggest.
    Saurabh.

    If you know how to use struts and portlets, you wouldn't be asking this question. I suggest looking into the Model-View Controller pattern to get an idea how to set up a web application, then think about how to do it in a portlet environment.

  • Open and close database connection jsp page

    hi there, i wanna know about how to open database connection to Mysql at the beginning of the page and close the connection at the end of the page. The jsp page contain all processing code.
    plz help me...thx thx

    <html>
    <head>
    <basefont face="Arial">
    </head>
    <body>
    <%@ page language="java" import="java.sql.*" %>
    <%!
    // define variables
    String id;
    String firstName;
    String lastName;
    // define database parameters, change this according to your needs
    String host="localhost";
    String user="root";
    String pass="";
    String db="test";
    String conn;
    %>
    <table border="1" cellspacing="1" cellpadding="5">
    <tr>
    <td><b>id</b></td>
    <td><b>first name</b></td>
    <td><b>last name</b></td>
    </tr>
    <%
    Class.forName("org.gjt.mm.mysql.Driver");
    // create connection string
    conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user 
    + "&password=" + pass;
    // pass database parameters to JDBC driver
    Connection Conn = DriverManager.getConnection(conn);
    // query statement
    Statement SQLStatement = Conn.createStatement();
    // generate query
    // change this query according to your needs
    String Query = "SELECT id, firstname, lastname FROM abook";
    // get result
    ResultSet SQLResult = SQLStatement.executeQuery(Query);
    while(SQLResult.next())
       id = SQLResult.getString("id");
       firstName = SQLResult.getString("firstname");
       lastName = SQLResult.getString("lastname");
            out.println("<tr><td>" + id + "</td><td>" + 
         firstName + "</td><td>" + lastName + "</td></tr>");
    // close connection
    SQLResult.close();
    SQLStatement.close();
    Conn.close();
    %>
    </table>
    </body>
    </html>hi :-)
    i've got that on the net as part of the tutorial on jsp (long long time ago)
    you just have to be resourceful in finding solutions :-)
    try google :-) there are lot's of tutorial available in there ;-)
    goodluck ;-)
    regards,

  • Access jsp pages in WEB-INF directory

    Hi,
    I've a problem with my jsp web project;
    practically I've created a web project that uses jsp pages and servlet.
    I never use links to jsp pages, directly in my web pages, but I call always first servlet;
    the servlet call jsp pages.
    My project is completed and works fine, but any user can access to my jsp pages directly simply writing the url.
    So I've tried to move my jsp pages in the WEB-INF directory, but now I doesn't manage in accessing index.jsp page;
    how must I do to access index.jsp page?
    I've tried to modify web.xml like this
    <welcome-file-list>
              <welcome-file>WEB-INF/index.jsp</welcome-file>
         </welcome-file-list>
    but doesn't work;
    besides also servlet calls to jsp pages doesn't work anymore.
    How can I solve?
    Thank you in advance
    MargNat

    ok, so first you have to implement the Filter interface, with 3 methods,
    the main method u have to put logic in is doFilter()
    public class YourClass implements javax.servlet.Filter {
    doFilter(ServletRequest req, ServletResponse res, FIlterChain chain) throws ... {
    //check first if is HTTP, if in this case permission is not granted as well
    if(req instanceof HttpServletRequest{
    HttpServletRequest httpReq = (HttpServletRequest)req;
    //now check if its called for index.jsp
    if(!httpReq.getRequestURI().toLowerCase().endsWith("index.jsp"))
       throw new ServletException("access permitted");
    else
      chain.doFilter(req,res); //go on with processing
    }else
    throw new ServletException("only HTTP requests allowed");
    }and of course you have to register that filter in your web.xml doing
      <filter>
        <filter-name>yourFilter</filter-name>
    <filter-class>yourFilterClass</filter-class>
      </filter>
      <filter-mapping>
        <filter-name>yourFilter</filter-name>
        <url-pattern>/**.jsp</url-pattern>
      </filter-mapping>actually that's it

  • Problem connecting oracle database to jsp pages using Apache Tomcat server 8.0

    Well...I tried too many things..googled so many times..but still could not find solution to my problem.
    I use windows 8 Enterprise Edition(if this has to do something with the problem)
    Oracle 11.2.0
    Apache Tomcat server 8.0
    JDK 1.7
    My oracle is installed in the D: drive and tomcat in c:. i copied the ojdbc6.jar file from oracle to lib directory of tomcat server.
    Then i set  CLASSPATH in environment variables as "C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib\ojdbc6.jar" in system variables
    My path variable is set as "C:\Program Files\Java\jdk1.7.0_02\bin".
    My program is as follows in notepad:
    <%@ page import="java.sql.*" %>
    <html>
    <body>
    <%
    Connection conn;
    Statement st;
    ResultSet rs;
    try{
    new oracle.jdbc.driver.OracleDriver();
    String dbURL="jdbc:odbc:oracle:thin:@localhost:1521:XE";
    String userId="system";
    String pwd="moon";
    conn=DriverManager.getConnection(dbURL,userId,pwd);
    st=conn.createStatement();
    rs= st.executeQuery("SELECT * FROM login");
    while(rs.next())
    System.out.println(rs.getString(1)+""+rs.getString(2));
    catch(Exception e){}
    %>
    </body>
    </html>
    I get too many errors then
    eroors
    org.apache.jasper.JasperException: An exception occurred processing JSP page /page2.jsp at line 14
    11: String userId="system";
    12: String pwd="moon";
    13:
    14: conn=DriverManager.getConnection(dbURL,userId,pwd);
    15: st=conn.createStatement();
    16:
    17: rs= st.executeQuery("SELECT * FROM login");
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    root cause
    javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:905)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:834)
         org.apache.jsp.page2_jsp._jspService(page2_jsp.java:102)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
         org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    Nothing solved this problem.

    >> Nothing solved this problem.
    Can't fix a problem 'till an actual problem is identified.
    >> ODBC Driver Manager ... Data source name not found
    That appears to be ODBC drivers looking for a DSN (Data Set Name). If it wants a DSN, the DSN has to be specified in the code, and the DSN has to be configured in the windows host ODBC applet. So that is at least two squirrels to get in the right tree before moving forward. A ...host:...[port:]SID|service name are some of the bits needed in a jdbc connect string, and that is in no way related to DSNs. A Whole Different Animal. If it wants a DSN that might be what needs to go in the URL bit.
    And ODBC setups can be confusing, especially if an x64 OS is in the mix- if that is the case there are two different ODBC configuration applets, one for x64 the other for x86, and if one gets as far as talking to an actual database it might toss an architecture error. Only way to fix that "problem" is *delete* the ODBC DSN and then run the correct (maybe the x86) ODBC config utility, and set up the DSN. Again.

  • Subject content missing access JSP page on Unix

    Hi, everyone:
              I've got a problem when I access my JSP page on unix system.The
              problem is that when I transfer a varable from one page to next. Some
              content are missing. But when I access this page on PC, no this
              problem.
              

    Hi Joseph,
              I have two JSP pages: messages page which has a reply link, it can
              link to replies page.
              <a href = "messages.jsp?CatName=<%= sCatName %>&CatID=<%= sCatID
              %>&MsgID=<%= sMsgID %>"><%=sHeader%></a>
              In this statement, sHeader will go to replies page. It should display
              on the Subject textbox, it is like our message reply interface. But on
              the replies page, only the first word be displayed, the following
              words is gone.
              Sorry, I don't understant what is WLS. And the Unix system which I
              used don't have JVM. Thanks for your reply.
              Joey Fan
              "Joseph Nguyen" <[email protected]> wrote in message news:<[email protected]>...
              > Hi Joey,
              >
              > What do you mean by "transfer" of a variable? Can you please elaborate and
              > provide the WLS version and service pack level along with the Unix
              > vendor/brand/version (and also JDK information)?
              >
              > Thanks,
              > Joseph Nguyen
              > BEA Support
              >
              > "joey" <[email protected]> wrote in message
              > news:[email protected]..
              > > Hi, everyone:
              > > I've got a problem when I access my JSP page on unix system.The
              > > problem is that when I transfer a varable from one page to next. Some
              > > content are missing. But when I access this page on PC, no this
              > > problem.
              

  • Display values from database in jsp page

    Hi,
    I need to display a list of options with checkboxes in a jsp page .The values are retrived from DB.
    formBean fb=new FormBean(request)
    <Input type="checkbox" name="xyz" value="<%=fb.getFormdata( "xyz")%>">
    should this"xyz" be the name of the column in the DB table?

    This is my FormBean
    public class FormBean {
    HttpServletRequest _request;
    public FormBean(HttpServletRequest request) {
    _request = request;
    public String getFormData(String abc) {
    return getFormData(abc, true);
    public String getFormData(String name, boolean filter) {
    String value = null;
    if (_request != null) {
    value = _request.getParameter(abc);
    if (value == null) value = "";
    if (filter) {
    value = Utils.filter(value);
    return value;
    * "Clears" parameters. Useful if you do wnat a form initialized with blanks rather than
    * current values;
    public void clear() {
    _request = null;
    }

  • Not able to connect to database through JSP page

    Hello Everyone,
    I'm creating a simple JSP page (helloworld.jsp) that would get info from the db and display it but when I point my browser to http://localhost:8080/helloworld.jsp, I get ClassNotFound exception.
    <html>
    <head>
    <title>My first JSP page
    </title>
    </head>
    <body>
    <%@page import="java.sql.*" %>
    <%
         try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         String url = "jdbc:mysql:///" + "trylnp";
         String user = "root";
         String pass = "welcome";
         Connection conn = DriverManager.getConnection(url,user,pass); 
         out.println("here");
         if((conn != null)&&(!conn.isClosed()))
              out.println("Connected...");
         String releasenum="3.1.48A";
         String query = "Select * from releasedata where releaseno='" + releasenum + "'; ";
         Statement s = conn.createStatement();
         ResultSet rs = s.executeQuery(query);
         while(rs.next())
              String useraction = rs.getString("useraction");
              String releaseno = rs.getString("releaseno");
              int ninetyfivepercentile = rs.getInt("ninetyfivepercentile");
              int ninetypercentile = rs.getInt("ninetypercentile");
              int fiftypercentile = rs.getInt("fiftypercentile");
              out.println("useraction : ");
              out.println("releaseno : ");
              out.println("ninetyfivepercentile : ");
              out.println("ninetypercentile : ");
              out.println("fiftypercentile : ");                    
         catch(Exception e ){
              out.println(e);
    %>
    </body>
    </html> I've properly set my classpath to C:\Program Files\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar
    and also put the jar file in all the WEB-INF sub folders inside C:\apache-tomcat-6.0.16\webapps (I know it had to go in one of the WEB-INF dir, but as I was not sure which one, I put the jar file in all of the WEB-INF folders)
    Please, do let me know if u know how to resolve the issue. It'll be a big help.
    Thanks.

    I've properly set my classpath to C:\Program Files\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jarI don't think that does anything. You aren't compiling a .java file.
    If you put mysql-connector-java-5.1.6-bin.jar in the directory:
    apache-tomcat-6.0.x/libit will be available to all your applications.
    After making a few changes to your code, the following worked for me:
    <html>
    <head>
    <title>My first JSP page</title>
    </head>
    <body>
    <%@page import="java.sql.*" %>
    <%
      try{
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      String url = "jdbc:mysql://localhost/mydb1";
      String user = "me";
      String pass = "jsptest";
      Connection conn = DriverManager.getConnection(url,user,pass);
      out.println("<div>here</div>");
      if((conn != null)&&(!conn.isClosed()))
        out.println("<div>Connected...</div>");
      String name="diane";
      String query = "Select * from mytable2 where name='" + name + "'" ; 
      Statement s = conn.createStatement();
      ResultSet rs = s.executeQuery(query);
      while(rs.next())
        //String useraction = rs.getString("useraction");
        //String releaseno = rs.getString("releaseno");
        //int ninetyfivepercentile = rs.getInt("ninetyfivepercentile");
        //int ninetypercentile = rs.getInt("ninetypercentile");
        //int fiftypercentile = rs.getInt("fiftypercentile");
        //out.println("useraction : ");
        //out.println("releaseno : ");
        //out.println("ninetyfivepercentile : ");
        //out.println("ninetypercentile : ");
        //out.println("fiftypercentile : ");       
        int id_result = rs.getInt("id");
        String name_result = rs.getString("name");
        out.println("<div>" + id_result + " - " + name_result + "</div>");
      catch(Exception e ){
        out.println("<div>something is wrong</div>");
        out.println("<div>" + e + "</div>");
    %>
    </body>
    </html>

  • Error while trying access JSP page first time using Oracle Lite

    Hi,
    We are doing a proof of concept using Oracle Lite 10gR3. Installed Mobile server and published a JSP based application. Installed web-to-go setup.exe on a client machine and synchronized the application. However when we tried to open the page, it comes up with an error. We are using jdk version 1.4. Any advise will be highly appreciated. Thanks.
    Error message:
    Requested URL:/webtogo/18Mar1/MyIndex.jsp
    Exception: oracle.classloader.util.AnnotatedClassFormatError:_MyIndex (Unsupported major.minor version 49.)
    Invalid Class: _MyIndex
    Loader:mobileclient.web.18Mar1.jsp22486527:0.0.0
    Code-Source: /C:/MyInstallation/mobile_client_oc4j/j2ee/mobileclient/application-deployments/mobileclient/18Mar1/persistence/_pages/
    Configuration: *.jsp in C:\MyInstallation\mobile_client_oc4j\j2ee\mobileclient\application-deployments\mobileclient\18Mar1\persistence\_pages
    Dependent Class: oracle.jsp.runtimev2.JspPageInfo
    Loader: oc4j:10.1.3
    Code-Source: /C:/MyInstallation/mobile_client_oc4j/j2ee/mobileclient/lib/ojsp.jar
    Configuration: <code-source> in META-INF/boot.xml in C:\MyInstallation\mobile_client_oc4j\j2ee\mobileclient\oc4j.jar
    This class was compiled for a newer version of the JRE. Expected version 48.0, found 49.0

    (Since this is the general forum for the 'big' database, my advice would be to ask in the Oracle Lite forum. Database Mobile Server (inc. legacy Database Lite)
    If this is a formal evaluation, you could also get a Sales-sponsored trial which usually comes with 30-90 days of Metalink support. You would be able to search for notes like Doc 414106.1
    Bottom line is that the code is for JDK 1.5 and it's being deployed against JDK 1.4.2. Something needs to be either upgraded or downgraded.

  • Access JSP pages under WEB-INF

    Hello, I have a web application and i use Java,JSP, servlets etc.
    In my webpage i have three different categories of users
    *1)* Registered users
    *2)* Not Registered users
    *3)* Administrator
    I would like the welcome page index.jsp and register page be accessed by everyone.
    But as far as the other pages are concerned , i would like to be accessed only by the registered users.
    What shall i do??
    I placed the index.jsp and register.jsp under the public folder and the other pages under WEB-INF folder in order to be accesses only from the registered users.
    But it's not working!
    What exactly shall i do in order to make that work??
    Thanks, in advance!

    g_p_java wrote:
    Thanks for the link! As i understood i don't have to place my web pages under WEB-INF (only the web.xml which is already there).
    *1)* So i have to follow the steps that are being mentioned there for all the users right??
    Registered , Not Registered and admin.
    Yes, security constraining through web.xml is a url pattern based protection for your resources. You could create multiple urls - /secured/* and map them to your resources accessible to registered users only or you may have /admin/* and define that only 'admin' roles have access to these resources. Some portions of such setup would be server specific (eg: how you create users and map them to roles)
    *2)* I would like to make a question: Who is the "FrontController" in the link you posted me? [http://onjava.com/onjava/2001/08/06/webform.html]
    It's the Container. Because such features are mandated by the spec, the container provides an implementation and options to customize the implementation (for example in weblogic, you can specify that your users are bound to an LDAP or configured in a Users table in the db)
    Nevertheless, you would have your own Controllers for your application management (Struts or Spring or whatever suits your need). On the same note, you should have your own Filters to implement whatever common logic you have across your application.
    Madathil_Prasad wrote:
    2. Write a filter that checks for the presence of a session (and entitlements possibly) before allowing access to a resource.
    *3)* when you write "_entitlements_" what exactly do you mean??
    Thanks!
    This is the other road I was talking about. You could throw all configuration and j2ee based security configuration out of the window (they do have their limitations) and implement custom security logic in a Filter. For example,
    String urlPattern = request.getRequestURI();
    if(urlPattern.indexOf("/secured") != null{
             if(request.getSession(false) == null){
                   //redirect to login page.
             }else{
                  //valid session
                  //now check specific entitlement to see whether user has access
    }Here entitlement refers to permissions at a granular level (authorization if you wish to call it). For example, you have 2 kinds of admin users - some who can generate reports of web activity and another who can change application settings.
    ram.

  • Autorefresh of a jsp page

    Hi,
    iam srinivas I have one doubt
    i'am inserting the row in database. from jsp page i'am retrieving that row. my doubt is when i insert the row in database at the same time it should be retrived from the jsp page simultaneously.I know this can be done using autoRefresh.but how can i autoRefresh the jsp page what is the procedure to autoRefresh the jsp page.other than autoRefresh
    is there any procedure please kindly help me

    why will you need an auto refresh?.. from what page are you inserting? same as the page that enters the data into the database?

  • JSP pages not working on app server but works locally

    Hello,
    My application uses java, struts and jsps. When I try to access JSP page like http://appServer:7778/app/login.jsp, it says page not found exception. But when I access http://appServer:7778/app/login.do, it displays login.jsp page (success url for login action is login.jsp). How come I am not able to access jsp pages directly? Am I missing any settings?
    And when I run the application using embedded OC4J of Jdeveloper, I could access jsp pages directly.
    Thanks.

    The method getTextContent() is DOM Level 3, and was introduced with Java1.5
    Tomcat 5.5 runs on Java1.5, but by default uses the JDT compiler for JSPs, which is only Java1.4 compliant - might possibly be that.
    See the [url http://tomcat.apache.org/tomcat-5.5-doc/RELEASE-NOTES.txt] release notes and
    [url http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html]how to fix (see the section on configuration)
    >
    The Java compiler from Eclipse JDT in included as the default compiler. It is an advanced Java compiler which will load all dependencies from the Tomcat class loader, which will help tremendously when compiling on large installations with tens of JARs. On fast servers, this will allow sub-second recompilation cycles for even large JSP pages. This new compiler will be updated to support the Java 5 syntax as soon as possible.
    Apache Ant, which was used in previous Tomcat releases, can be used instead instead of the new compiler by simply removing the common/lib/jasper-compiler-jdt.jar file, and placing the ant.jar file from the latest Ant distribution in the common/lib folder. If you do this, you also need to use the "javac" argument to catalina.sh.

  • Unable to access values from database in login page..

    Hey all,
    Friends I have a login.jsp page and I want if i enter username and password then it will be accessed from database and after verifying the details it will open main.jsp.I made a database as "abc" and created DSN as 1st_login having table 1st_login. But the problem is that I am unable to access values from database.
    So Please help me.
    Following is my code:
    <HTML>
    <body background="a.jpg">
    <marquee>
                        <CENTER><font size="5" face="times" color="#993300"><b>Welcome to the"<U><I>XYZ</I></U>" of ABC</font></b></CENTER></marquee>
              <br>
              <br>
              <br>
              <br><br>
              <br>
         <form name="login_form">
              <CENTER><font size="4" face="times new roman">
    Username          
              <input name="username" type="text" class="inputbox" alt="username" size="20"  />
              <br>
         <br>
              Password          
              <input type="password" name="pwd" class="inputbox" size="20" alt="password" />
              <br/>
              <input type="hidden" name="option" value="login" />
              <br>
              <input type="SUBMIT" name="SUBMIT" class="button" value="Submit" onClick="return check();"> </CENTER>
              </td>
         </tr>
         <tr>
              <td>
              </form>
              </table>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connection = DriverManager.getConnection("jdbc:odbc:1st_login");
    Statement statement = connection.createStatement();
    String query = "SELECT username, password FROM 1st_login WHERE username='";
    query += request.getParameter("username") + "' AND password='";
    query += request.getParameter("password") + "';";
    ResultSet resSum = statement.executeQuery(query);
    //change: you gotta move the pointer to the first row of the result set.
    resSum.next();
    if (request.getParameter("username").equalsIgnoreCase(resSum.getString("username")) && request.getParameter("password").equalsIgnoreCase(resSum.getString("password")))
    %>
    //now it must connected to next page..
    <%
    else
    %>
    <h2>You better check your username and password!</h2>
    <%
    }catch (SQLException ex ){
    System.err.println( ex);
    }catch (Exception er){
    er.printStackTrace();
    %>
    <input type="hidden" name="op2" value="login" />
         <input type="hidden" name="lang" value="english" />
         <input type="hidden" name="return" value="/" />
         <input type="hidden" name="message" value="0" />
         <br>
              <br><br>
              <br><br>
              <br><br><br><br><br>
              <font size="2" face="arial" color="#993300">
         <p align="center"> <B>ABC &copy; PQR</B>
    </BODY>
    </HTML>
    and in this code i am getting following error
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:93: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:94: cannot find symbol_
    C:\Project\SRS\build\generated\src\org\apache\jsp\loginjsp.java:95: cannot find symbol_
    4 errors
    C:\Project\SRS\nbproject\build-impl.xml:360: The following error occurred while executing this line:
    C:\Project\SRS\nbproject\build-impl.xml:142: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 6 seconds)

    As long as you're unable to compile Java code, please use the 'New to Java' forum. This is really trival.
    To ease writing, debugging and maintenance, I highly recommend you to write Java code in Java classes rather than JSP files. Start learning Servlets.

  • How to retrieve records from a database and display it in a jsp page.Help!!

    Hello everyone ! im very new to this forum.Please help me to solve my problem
    First i ll explain what is my requirement or needed.
    Actually in my web page i have text box to enter start date and end date
    and one list box to select the month .If user select or enter the dates in text box
    accordingly the data from ms access database has to display in a jsp page.
    Im using jsp and beans.
    I tried returning ResultSet from bean but i get nothing display in my web page
    instead it goes to error page (ErrorPage.jsp) which i handle in the jsp.
    I tried many things but nothing work out please help me to attain a perfect
    solution. I tried with my bean individually to check whether the result set has
    values but i got NullPointerException . But the values which i passed or
    available in the database.
    I dint get any reply for my last post please reply atleast to this.
    i get the date in the jsp page is by this way
    int Year=Integer.parseInt(request.getParameter("year"));
    int Month=Integer.parseInt(request.getParameter("month"));
    int Day=Integer.parseInt(request.getParameter("day"));
    String startdate=Day+"/"+Month+"/"+Year;
    int Year1=Integer.parseInt(request.getParameter("year1"));
    int Month1=Integer.parseInt(request.getParameter("month1"));
    int Day1=Integer.parseInt(request.getParameter("day1"));
    String enddate=Day1+"/"+Month1+"/"+Year1;But this to check my bean whether it return any result!
    public void databaseConnection(String MTName,String startDate,String endDate)
    try
             java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("dd/MM/yyyy");
             java.util.Date fromDate=dateFormat.parse(startDate);
            java.util.Date tillDate=dateFormat.parse(endDate);          
            java.sql.Date sqlFromDate=new java.sql.Date(fromDate.getTime());
            java.sql.Date sqlTillDate=new java.sql.Date(tillDate.getTime());
              String query1="select MTName,Date,MTLineCount from Main where MTName='"+MTName+"'  and Date between '"+sqlFromDate+"' and '"+sqlTillDate+"' " ;
            System.out.println(query1);
              Class.forName(driver);
             DriverManager.getConnection(url);
             preparedStatement=connection.prepareStatement(query1);
             preparedStatement.setString(1,"MTName");
              preparedStatement.setDate(2,sqlFromDate);
              preparedStatement.setDate(3,sqlTillDate);
              resultSet=preparedStatement.executeQuery();           
               while(resultSet.next())
                        System.out.println(resultSet.getString(1));
                        System.out.println(resultSet.getDate(2));
                        System.out.println(resultSet.getInt(3));
            catch (Exception e)
             e.printStackTrace();
    I Passed value from my main method is like thisl
    databaseConnection("prasu","1/12/2005","31/12/2005");Please provide solutions or provide some sample codes!
    Help!
    Thanks in advance for replies

    Thanks for ur reply Mr.Rajasekhar
    I tried as u said,
    i tried without converting to sql date ,but still i din't get any results
    java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("dd/MM/yyyy");
             java.util.Date fromDate=dateFormat.parse(startDate);
            java.util.Date tillDate=dateFormat.parse(endDate);          
              String query1="select MTName,Date,MTLineCount from linecountdetails where mtname='"+MTName+"'  and Date >='"+fromDate+"' and Date <='"+tillDate+"' " ;
            System.out.println(query1);
    //From main method
    databaseConnection("prasu","1/12/2005","31/12/2005");I got the output as
    ---------- java ----------
    select MTName,Date,MTLineCount from linecountdetails where mtname='prasu'  and Date >='Thu Dec 01 00:00:00 GMT+05:30 2005' and Date <='Sat Dec 31 00:00:00 GMT+05:30 2005'
    java.lang.NullPointerException
    null
    null
    java.lang.NullPointerException
    Output completed (4 sec consumed) - Normal TerminationThanks
    Prasanna.B

  • How to access a static method inside the JSP page

    Here i had wrote the code in java to access databases , i had include the class path to all the class files.
    my problem is when i click the register.jsp page, it will pose eror as null pointer exception i've put my code in this section as follows
    memberchecking.jsp
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*,businessclasses.*,businessobjects.*,projectutils.DateUtilities.*,java.util.*" errorPage="" %>
    <html>
    <head>
    <title>Checking Member's Registration Details...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <%
    String loginId = request.getParameter("loginId");
    String resourcePassword = request.getParameter("resourcePassword");
    String confirmPassword = request.getParameter("confirmPassword");
    String resourceStatus=request.getParameter("resourceStatus");
    String nameTitle = request.getParameter("nameTitle");
    String jobTitle = request.getParameter("jobTitle");
    String firstName = request.getParameter("firstName");
    String middleName = request.getParameter("middleName");
    String lastName = request.getParameter("lastName");
    String displayName = request.getParameter("displayName");
    String resourceInitials = request.getParameter("resourceIniitials");
    String countryCode = request.getParameter("countryCode");
    String resourceLanguage = request.getParameter("resourceLanguage");
    //String resourceCurrency = request.getParameter("resourceCurrency");
    String resourceEmail2 = request.getParameter("resourceEmail2");
    String birthMonth = request.getParameter("birthMonth");
    String birthDay = request.getParameter("birthDay");
    String birthYear = request.getParameter("birthYear");
    String resourceGender = request.getParameter("resourceGender");
    String martialStatus = request.getParameter("martialStatus");
    String resourceOccupation = request.getParameter("resourceOccupation");
    String webPage = request.getParameter("webPage");
    String homePhone = request.getParameter("homePhone");
    String homePhone2 = request.getParameter("homephone2");
    String homeFax = request.getParameter("homepFax");
    String phoneOffice = request.getParameter("phoneOffice");
    String phoneOffice2 = request.getParameter("phoneOffice2");
    String officeFax = request.getParameter("officeFax");
    String resourcePager = request.getParameter("resourcePager");
    String resourceMobile = request.getParameter("resourceMobile");
    String resourceType=request.getParameter("resourceType");
    String resourceName = firstName + " " + middleName + " " + lastName;
    //java.util.Date resourceBirthDate = (String)birthMonth + "/" + birthDay + "/" + birthYear;
    session.setAttribute("Name",resourceName);
    session.setAttribute("UserId",loginId);
    out.println("name==========="+resourceName);
    //check whether the input data is valid for insert
    //input validation code goes here.....
    ResourceBC aResourceBC=new ResourceBC();
    //marshall the resource
    ResourceBO resource=new ResourceBO();
    String e1 = (String)resource.getEmail();
    String e2 = (String)resource.getEmail2();
    if(loginId != e1 && resourceEmail2 != e2 ) {
              resource.setStatus( "L");
              resource.setId(5);
              resource.setCountryCode(countryCode);
         //     resource.setResourceTypeCode(resourceType);     
         //     resource.setResourceParent(rs.getLong(6));
         //     resource.setHKey(rs.getLong(7));          
              resource.setName(resourceName);
              resource.setDisplayName(displayName);
              resource.setLogonPassword(resourcePassword);
              resource.setNameTitle(nameTitle);
              resource.setJobTitle(jobTitle);
              resource.setEmail(loginId);
              resource.setEmail2(resourceEmail2);          
         //     resource.setPasswordUpdateDate(rs.getDate(14));
         //     resource.setPasswordExpireDate(rs.getDate(15));
         //     resource.setAccessCode(rs.getString(16));
         //     resource.setLogonUnSuccessTries(0);
              resource.setWebPage(webPage);
              resource.setPhoneOffice(phoneOffice);
              resource.setPhoneOffice2(phoneOffice2);
              resource.setPhoneOfficeFax(officeFax);
              resource.setPhoneHome(homePhone);
              resource.setPhoneHome2(homePhone2);
              resource.setPhoneHomeFax(homeFax);
              resource.setMobile(resourceMobile);
              resource.setPager(resourcePager);
              resource.setStatus(resourceStatus);     
              resource.setGender(resourceGender);     
         //     resource.setBirthDate(resourceBirthDate);
              resource.setMartialStatus(martialStatus);
              resource.setLanguage(resourceLanguage);
    //          resource.setCurrency(resourceCurrency);
    //          resource.setPhoto(photo);
              resource.setInitials(resourceInitials);                         
    //          resource.setCreatedBy(1);
    //          resource.setCreatedDate(rs.getDate(36));
    //          resource.setUpdatedBy(rs.getLong(37));
    //          resource.setUpdatedDate(rs.getDate(38));
              resource.setFirstName(firstName);
              resource.setLastName(lastName);
              resource.setMiddleName(middleName);     
              //resource.setCreatedDate(new java.sql.Date());
              int rowsAdded=aResourceBC.resourceAdd(resource);
              out.println("rowsAdded= "+rowsAdded);
              //add message for success or failure to add resource
              String msg="";
              if(rowsAdded == -1){
                   msg="<font color=red>The ResourceName already exists .Try another</font>";
                   session.setAttribute("message",msg);
                   response.sendRedirect(response.encodeRedirectURL("memberregister.jsp"));
              else if(rowsAdded > 0){
                   msg="<font color=green>Resource Added successfully..........</font>";     
                   session.setAttribute("message",msg);
    %>
                   <jsp:forward page="memberlist.jsp">
                   <jsp:param name="message" value="<%=msg%>"/>
                   </jsp:forward>
    <%}
    %>
    </body>
    </html>
    ResourceBC.java
    package businessclasses;
    import java.sql.*;
    import businessobjects.ResourceBO;
    import java.util.*;
    import dbutilities.DBManager;
    public class ResourceBC
         public Vector resourceList() throws Exception{
         Vector resourceList=new Vector();
         String listSQL="";
         StringBuffer listSQLBuffer=new StringBuffer();
         listSQLBuffer.append("SELECT ");
         listSQLBuffer.append("RES_ID,");
         listSQLBuffer.append("RES_NAME,");
         listSQLBuffer.append("CNTRY_CODE,");
         listSQLBuffer.append("RES_LOGON_PASSWORD,");
         listSQLBuffer.append("RESTYPE_CODE,");
         listSQLBuffer.append("RES_PARENT,");
         listSQLBuffer.append("RES_HKEY,");
         listSQLBuffer.append("RES_DISPLAY_NAME,");
         listSQLBuffer.append("RES_NAME_TITLE,");     
         listSQLBuffer.append("RES_JOB_TITLE,");     
         listSQLBuffer.append("RES_EMAIL,");
         listSQLBuffer.append("RES_EMAIL2,");     
         listSQLBuffer.append("RES_PASSWORD_ACTION,");     
         listSQLBuffer.append("RES_PASSWORD_UPDATE_DATE,");     
         listSQLBuffer.append("RES_PASSWORD_EXPIRE_DATE,");     
         listSQLBuffer.append("RES_ACCESS_CODE,");     
         listSQLBuffer.append("RES_LOGON_UNSUCCESS_TRIES,");     
         listSQLBuffer.append("RES_WEB_PAGE,");
         listSQLBuffer.append("RES_PHONE_OFFICE,");
         listSQLBuffer.append("RES_PHONE_OFFICE2,");
         listSQLBuffer.append("RES_PHONE_OFFICE_FAX,");
         listSQLBuffer.append("RES_PHONE_HOME,");
         listSQLBuffer.append("RES_PHONE_HOME2,");
         listSQLBuffer.append("RES_PHONE_HOME_FAX,");
         listSQLBuffer.append("RES_MOBILE,");
         listSQLBuffer.append("RES_PAGER,");
         listSQLBuffer.append("RES_STATUS,");
         listSQLBuffer.append("RES_GENDER,");
         listSQLBuffer.append("RES_BIRTH_DATE,");
         listSQLBuffer.append("RES_MARTIAL_STATUS,");
         listSQLBuffer.append("RES_LANGUAGE,");
         listSQLBuffer.append("RES_CURRENCY,");
         listSQLBuffer.append("RES_PHOTO,");
         listSQLBuffer.append("RES_CREATED_BY,");
         listSQLBuffer.append("RES_NAME_INITIALS,");          
         listSQLBuffer.append("RES_CREATED_DATE,");
         listSQLBuffer.append("RES_UPDATED_BY");
         listSQLBuffer.append("RES_UPDATED_DATE,");
         listSQLBuffer.append("RES_NAME_FIRST,");
         listSQLBuffer.append("RES_NAME_LAST,");
         listSQLBuffer.append("RES_NAME_MIDDLE");     
         listSQLBuffer.append(" FROM T_RESOURCES ");
         listSQL=listSQLBuffer.toString();
    System.out.println("listSQL---"+listSQL);
         DBManager dbManager=new DBManager();
         Connection con =dbManager.getConnection();
         Statement stmt=con.createStatement();
         ResultSet rs=stmt.executeQuery(listSQL);
         ResourceBO resource=null;
         while(rs.next()){
              resource=new ResourceBO();
              resource.setId(rs.getLong(1));
              resource.setName(rs.getString(2));
              resource.setCountryCode(rs.getString(3));
              resource.setLogonPassword(rs.getString(4));
              resource.setResourceTypeCode(rs.getLong(5));     
              resource.setResourceParent(rs.getLong(6));
              resource.setHKey(rs.getLong(7));          
              resource.setDisplayName(rs.getString(8));
              resource.setNameTitle(rs.getString(9));
              resource.setJobTitle(rs.getString(10));
              resource.setEmail(rs.getString(11));
              resource.setEmail2(rs.getString(12));          
              resource.setPasswordAction(rs.getString(13));
              resource.setPasswordUpdateDate(rs.getDate(14));
              resource.setPasswordExpireDate(rs.getDate(15));
              resource.setAccessCode(rs.getString(16));
              resource.setLogonUnSuccessTries(rs.getLong(17));
              resource.setWebPage(rs.getString(18));
              resource.setPhoneOffice(rs.getString(19));
              resource.setPhoneOffice2(rs.getString(20));
              resource.setPhoneOfficeFax(rs.getString(21));
              resource.setPhoneHome(rs.getString(22));
              resource.setPhoneHome2(rs.getString(23));
              resource.setPhoneHomeFax(rs.getString(24));
              resource.setMobile(rs.getString(25));
              resource.setPager(rs.getString(26));
              resource.setStatus(rs.getString(27));     
              resource.setGender(rs.getString(28));     
              resource.setBirthDate(rs.getDate(29));
              resource.setMartialStatus(rs.getString(30));
              resource.setLanguage(rs.getString(31));
              resource.setCurrency(rs.getString(32));
              resource.setPhoto(rs.getString(33));
              resource.setCreatedBy(rs.getLong(34));
              resource.setInitials(rs.getString(35));                         
              resource.setCreatedDate(rs.getDate(36));
              resource.setUpdatedBy(rs.getLong(37));
              resource.setUpdatedDate(rs.getDate(38));
              resource.setFirstName(rs.getString(39));
              resource.setLastName(rs.getString(40));
              resource.setMiddleName(rs.getString(41));          
              resourceList.add(resource);
              con.close();
              con=null;
              return resourceList;
    //Method to insert the values into the database
    public int resourceAdd(ResourceBO resource){
         System.out.println("in resourceAdd method ");
         //check for duplicate record in the table
         String checkDuplicationSQL="SELECT RES_ID FROM T_RESOURCES WHERE RES_ID='"+resource.getId()+"'";     
         DBManager dbManager=new DBManager();//.getInstance();
         boolean hasDuplicateRecord=dbManager.hasDuplicateRecord(checkDuplicationSQL);
         int rowsAdded=0;
         //insert the record
         //hasDuplicateRecord=false;
              if(!hasDuplicateRecord){
                   //get the next resource id for insertion
              long nextID=dbManager.getNextIDForColumnAndTable("RES_ID","T_RESOURCES");
              System.out.println("nextID================== "+nextID);
    StringBuffer fieldsbuffer=new StringBuffer();
         fieldsbuffer.append("INSERT INTO T_RESOURCES (");
         fieldsbuffer.append("RES_ID,");
         fieldsbuffer.append("RES_NAME,");
         fieldsbuffer.append("CNTRY_CODE,");
         fieldsbuffer.append("RES_LOGON_PASSWORD,");
         fieldsbuffer.append("RESTYPE_CODE,");     
         fieldsbuffer.append("RES_PARENT,");
         fieldsbuffer.append("RES_HKEY,");
         fieldsbuffer.append("RES_DISPLAY_NAME,");     
         fieldsbuffer.append("RES_NAME_TITLE,");
         fieldsbuffer.append("RES_JOB_TITLE,");
         fieldsbuffer.append("RES_EMAIL,");
         fieldsbuffer.append("RES_EMAIL2,");
         fieldsbuffer.append("RES_PASSWORD_ACTION,");
         fieldsbuffer.append("RES_PASSWORD_UPDATE_DATE,");          
         fieldsbuffer.append("RES_PASSWORD_EXPIRE_DATE,");          
         fieldsbuffer.append("RES_ACCESS_CODE,");          
         fieldsbuffer.append("RES_LOGON_UNSUCCESS_TRIES,");     
         fieldsbuffer.append("RES_WEB_PAGE,");
         fieldsbuffer.append("RES_PHONE_OFFICE,");
         fieldsbuffer.append("RES_PHONE_OFFICE2,");
         fieldsbuffer.append("RES_PHONE_OFFICE_FAX,");
         fieldsbuffer.append("RES_PHONE_HOME,");
         fieldsbuffer.append("RES_PHONE_HOME2,");
         fieldsbuffer.append("RES_PHONE_HOME_FAX,");
         fieldsbuffer.append("RES_MOBILE,");
         fieldsbuffer.append("RES_PAGER,");
         fieldsbuffer.append("RES_STATUS,");     
         fieldsbuffer.append("RES_GENDER,");     
         fieldsbuffer.append("RES_BIRTH_DATE,");          
         fieldsbuffer.append("RES_MARTIAL_STATUS,");          
         fieldsbuffer.append("RES_LANGUAGE,");          
         fieldsbuffer.append("RES_CURRENCY,");          
         fieldsbuffer.append("RES_PHOTO,");     
    /*     fieldBuffer.append("RES_CREATED_BY,");
         fieldBuffer.append("RES_NAME_INITIALS,");          
         fieldBuffer.append("RES_CREATED_DATE,");
         fieldBuffer.append("RES_UPDATED_BY");
         fieldBuffer.append("RES_UPDATED_DATE,");
         fieldBuffer.append("RES_NAME_FIRST,");
         fieldBuffer.append("RES_NAME_LAST,");
         fieldBuffer.append("RES_NAME_MIDDLE");     */
         StringBuffer valuesBuffer=new StringBuffer(" VALUES(");
    valuesBuffer.append(nextID+",");
         valuesBuffer.append("'"+resource.getName()+",");
         valuesBuffer.append("'"+resource.getCountryCode()+",");
         valuesBuffer.append("'"+resource.getLogonPassword()+"',");
         valuesBuffer.append("'"+resource.getResourceTypeCode()+",");
         valuesBuffer.append("'"+resource.getResourceParent()+",");
         valuesBuffer.append("'"+resource.getHKey()+",");
         valuesBuffer.append("'"+resource.getDisplayName()+",");
         valuesBuffer.append("'"+resource.getNameTitle()+",");
         valuesBuffer.append("'"+resource.getJobTitle()+",");
         valuesBuffer.append("'"+resource.getEmail()+"',");
         valuesBuffer.append("'"+resource.getEmail2()+"',");
         valuesBuffer.append("'"+resource.getPasswordAction()+",");
         valuesBuffer.append("'"+resource.getPasswordUpdateDate()+",");
         valuesBuffer.append("'"+resource.getPasswordExpireDate()+",");
         valuesBuffer.append("'"+resource.getAccessCode()+",");
         valuesBuffer.append("'"+resource.getLogonUnsuccessTries()+",");     
         valuesBuffer.append("'"+resource.getWebPage()+"',");
         valuesBuffer.append("'"+resource.getPhoneOffice()+"',");
         valuesBuffer.append("'"+resource.getPhoneOffice2()+"',");
         valuesBuffer.append("'"+resource.getPhoneOfficeFax()+"',");
         valuesBuffer.append("'"+resource.getPhoneHome()+"',");
         valuesBuffer.append("'"+resource.getPhoneHome2()+"',");
         valuesBuffer.append("'"+resource.getPhoneHomeFax()+"',");
         valuesBuffer.append("'"+resource.getMobile()+"',");
         valuesBuffer.append("'"+resource.getPager()+"',");
         valuesBuffer.append("'"+resource.getStatus()+"',");
         valuesBuffer.append("'"+resource.getGender()+"',");
         valuesBuffer.append("'"+resource.getBirthDate()+"',");
         valuesBuffer.append("'"+resource.getMartialStatus()+"',");
         valuesBuffer.append("'"+resource.getLanguage()+"',");
         valuesBuffer.append("'"+resource.getCurrency()+"',");
         valuesBuffer.append("'"+resource.getPhoto()+"',");
         valuesBuffer.append("'"+resource.getCreatedBy()+"',");
         valuesBuffer.append("'"+resource.getInitials()+"',");
         valuesBuffer.append("'"+resource.getCreatedDate()+"',");
         valuesBuffer.append("'"+resource.getUpdatedBy()+"',");
         valuesBuffer.append("'"+resource.getUpdatedDate()+"',");
         valuesBuffer.append("'"+resource.getFirstName()+"',");
         valuesBuffer.append("'"+resource.getLastName()+"',");
         valuesBuffer.append("'"+resource.getMiddleName()+"')");
         String insertSQL=fieldsbuffer.toString()+valuesBuffer.toString();
              System.out.println("insertSQL="+insertSQL);
              rowsAdded=dbManager.executeSQL(insertSQL);
              System.out.println("rowsAdded= "+rowsAdded+"hasDuplicateRecord "+hasDuplicateRecord);
              }//end if
              else{
                   //throw new Exception("Has a duplicate Record");
                   return -1;
              return rowsAdded;
    public int resourceUpdate(ResourceBO resource){
              int rowsUpdated=0;
    /*          String orgCodeStr=null;
              if(resource.getOrgCode()==0){
                   orgCodeStr="NULL";
         }else{
                   orgCodeStr=""+resource.getOrgCode();
              StringBuffer updateSQLBuffer=new StringBuffer();
         updateSQLBuffer.append("UPDATE T_RESOURCES SET ");          
         updateSQLBuffer.append("RES_NAME='"+resource.getName()+"',");
         updateSQLBuffer.append("CNTRY_CODE='"+resource.getCountryCode()+"',");
         updateSQLBuffer.append("RES_LOGON_PASSWORD='"+resource.getLogonPassword()+"',");
         updateSQLBuffer.append("RESTYPE_CODE="+resource.getResourceTypeCode()+",");
         updateSQLBuffer.append("RES_PARENT="+resource.getResourceParent()+",");
         updateSQLBuffer.append("RES_HKEY="+resource.getHKey()+",");
         updateSQLBuffer.append("RES_DISPLAY_NAME="+resource.getDisplayName()+",");
         updateSQLBuffer.append("RES_NAME_TITLE="+resource.getNameTitle()+",");
         updateSQLBuffer.append("RES_JOB_TITLE="+resource.getJobTitle()+",");
         updateSQLBuffer.append("RES_EMAIL='"+resource.getEmail()+"',");
         updateSQLBuffer.append("RES_EMAIL2='"+resource.getEmail2()+"',");
         updateSQLBuffer.append("RES_PASSWORD_ACTION="+resource.getPasswordAction()+",");
         updateSQLBuffer.append("RES_PASSWORD_UPDATE_DATE="+resource.getPasswordUpdateDate()+",");
         updateSQLBuffer.append("RES_PASSWORD_EXPIRE_DATE="+resource.getPasswordExpireDate()+",");
         updateSQLBuffer.append("RES_ACCESS_CODE="+resource.getAccessCode()+",");
         updateSQLBuffer.append("RES_LOGON_UNSUCCESS_TRIES="+resource.getLogonUnsuccessTries()+",");     
         updateSQLBuffer.append("RES_WEB_PAGE='"+resource.getWebPage()+"',");
         updateSQLBuffer.append("RES_PHONE_OFFICE='"+resource.getPhoneOffice()+"',");
         updateSQLBuffer.append("RES_PHONE_OFFICE2='"+resource.getPhoneOffice2()+"',");
         updateSQLBuffer.append("RES_PHONE_OFFICE_FAX='"+resource.getPhoneOfficeFax()+"',");
         updateSQLBuffer.append("RES_PHONE_HOME='"+resource.getPhoneHome()+"',");
         updateSQLBuffer.append("RES_PHONE_HOME2='"+resource.getPhoneHome2()+"',");
         updateSQLBuffer.append("RES_PHONE_HOME_FAX='"+resource.getPhoneHomeFax()+"',");
         updateSQLBuffer.append("RES_MOBILE='"+resource.getMobile()+"',");
         updateSQLBuffer.append("RES_PAGER='"+resource.getPager()+"',");
         updateSQLBuffer.append("RES_STATUS='"+resource.getStatus()+"',");
         updateSQLBuffer.append("RES_GENDER='"+resource.getGender()+"',");
         updateSQLBuffer.append("RES_BIRTH_DATE='"+resource.getBirthDate()+"',");
         updateSQLBuffer.append("RES_MARTIAL_STATUS='"+resource.getMartialStatus()+"',");
         updateSQLBuffer.append("RES_LANGUAGE='"+resource.getLanguage()+"',");
         updateSQLBuffer.append("RES_CURRENCY='"+resource.getCurrency()+"',");
         updateSQLBuffer.append("RES_PHOTO='"+resource.getPhoto()+"',");
         updateSQLBuffer.append("RES_NAME_INITIALS='"+resource.getInitials()+"',");
         updateSQLBuffer.append("RES_NAME_FIRST='"+resource.getFirstName()+"',");
         updateSQLBuffer.append("RES_NAME_LAST='"+resource.getLastName()+"',");
         updateSQLBuffer.append("RES_NAME_MIDDLE='"+resource.getMiddleName()+"'");
         updateSQLBuffer.append("WHERE RES_ID="+resource.getId());
         String updateSQL=updateSQLBuffer.toString();
              //String updateSQL="UPDATE T_RESOURCES SET CLIENT_NAME='"+resource.getName()+"',CLIENT_STATUS='"+resource.getStatus()+"',CLIENT_EMAIL_PRIMARY='"+resource.getEmailPrimary()+"',CLIENT_EMAIL_ALTERNATIVE='"+resource.getEmailAlternate()+"',CLIENT_CURRENCY_SYMBOL='"+resource.getCurrencySymbol()+"',CLIENT_CURRENCY_DIGITS="+resource.getCurrencyDigits()+",CLIENT_DIRECTORY_DOCUMENT='"+resource.getDirectoryDocument()+"',CLIENT_DIRECTORY_TEMPLATE='"+resource.getDirectoryTemplate()+"',CLIENT_STORAGE_QUOTA="+resource.getStorageQuota()+",CLIENT_KEY='"+resource.getKey()+"' WHERE CLIENT_ID="+resource.getId();
              System.out.println("updateSQL---"+updateSQL);
              DBManager dbManager=new DBManager();
              rowsUpdated=dbManager.executeSQL(updateSQL);
              return rowsUpdated;
    public int resourceDelete(long resourceId){
              int rowsDeleted=0;
              DBManager dbManager=new DBManager();
              String deleteSQL="DELETE FROM T_RESOURCES WHERE RES_ID="+resourceId;
              System.out.println("deleteSQL==="+deleteSQL);
              rowsDeleted=dbManager.executeSQL(deleteSQL);
              System.out.println("rowsDeleted= "+rowsDeleted);
              return rowsDeleted;
    public ResourceBO getResourceById(long resourceId)throws Exception{
              StringBuffer selectSQLBuffer=new StringBuffer();
              selectSQLBuffer.append("SELECT ");
              selectSQLBuffer.append("RES_ID,");
              selectSQLBuffer.append("RES_NAME,");
              selectSQLBuffer.append("CNTRY_CODE,");
              selectSQLBuffer.append("RES_LOGON_PASSWORD,");
              selectSQLBuffer.append("RESTYPE_CODE,");
              selectSQLBuffer.append("RES_PARENT,");
              selectSQLBuffer.append("RES_HKEY,");
              selectSQLBuffer.append("RES_DISPLAY_NAME,");
              selectSQLBuffer.append("RES_NAME_TITLE,");          
              selectSQLBuffer.append("RES_JOB_TITLE,");     
              selectSQLBuffer.append("RES_EMAIL,");
              selectSQLBuffer.append("RES_EMAIL2,");     
              selectSQLBuffer.append("RES_PASSWORD_ACTION,");     
              selectSQLBuffer.append("RES_PASSWORD_UPDATE_DATE,");     
              selectSQLBuffer.append("RES_PASSWORD_EXPIRE_DATE,");     
              selectSQLBuffer.append("RES_ACCESS_CODE,");     
              selectSQLBuffer.append("RES_LOGON_UNSUCCESS_TRIES,");     
              selectSQLBuffer.append("RES_WEB_PAGE,");
              selectSQLBuffer.append("RES_PHONE_OFFICE,");
              selectSQLBuffer.append("RES_PHONE_OFFICE2,");
              selectSQLBuffer.append("RES_PHONE_OFFICE_FAX,");
              selectSQLBuffer.append("RES_PHONE_HOME,");
              selectSQLBuffer.append("RES_PHONE_HOME2,");
              selectSQLBuffer.append("RES_PHONE_HOME_FAX,");
              selectSQLBuffer.append("RES_MOBILE,");
              selectSQLBuffer.append("RES_PAGER,");
              selectSQLBuffer.append("RES_STATUS,");
              selectSQLBuffer.append("RES_GENDER,");
              selectSQLBuffer.append("RES_BIRTH_DATE,");
              selectSQLBuffer.append("RES_MARTIAL_STATUS,");
              selectSQLBuffer.append("RES_LANGUAGE,");
              selectSQLBuffer.append("RES_CURRENCY,");
              selectSQLBuffer.append("RES_PHOTO,");
              selectSQLBuffer.append("RES_CREATED_BY,");
              selectSQLBuffer.append("RES_NAME_INITIALS,");          
              selectSQLBuffer.append("RES_CREATED_DATE,");
              selectSQLBuffer.append("RES_UPDATED_BY");
              selectSQLBuffer.append("RES_UPDATED_DATE,");
              selectSQLBuffer.append("RES_NAME_FIRST,");
              selectSQLBuffer.append("RES_NAME_LAST,");
              selectSQLBuffer.append("RES_NAME_MIDDLE");     
              selectSQLBuffer.append(" FROM T_RESOURCES WHERE RES_ID="+resourceId);
              String fetchSQL=selectSQLBuffer.toString();
    System.out.println("fetchSQL---"+fetchSQL);
                   DBManager dbManager=new DBManager();
                   Connection con =dbManager.getConnection();
                   Statement stmt=con.createStatement();
                   ResultSet rs=stmt.executeQuery(fetchSQL);
                   ResourceBO resource=new ResourceBO();
                   while(rs.next()){                    
                   resource.setId(rs.getLong(1));
                   resource.setName(rs.getString(2));
                   resource.setCountryCode(rs.getString(3));
                   resource.setLogonPassword(rs.getString(4));
                   resource.setResourceTypeCode(rs.getLong(5));     
                   resource.setResourceParent(rs.getLong(6));
                   resource.setHKey(rs.getLong(7));          
                   resource.setDisplayName(rs.getString(8));
                   resource.setNameTitle(rs.getString(9));
                   resource.setJobTitle(rs.getString(10));
                   resource.setEmail(rs.getString(11));
                   resource.setEmail2(rs.getString(12));          
                   resource.setPasswordAction(rs.getString(13));
                   resource.setPasswordUpdateDate(rs.getDate(14));
                   resource.setPasswordExpireDate(rs.getDate(15));
                   resource.setAccessCode(rs.getString(16));
                   resource.setLogonUnSuccessTries(rs.getLong(17));
                   resource.setWebPage(rs.getString(18));
                   resource.setPhoneOffice(rs.getString(19));
                   resource.setPhoneOffice2(rs.getString(20));
                   resource.setPhoneOfficeFax(rs.getString(21));
                   resource.setPhoneHome(rs.getString(22));
                   resource.setPhoneHome2(rs.getString(23));
                   resource.setPhoneHomeFax(rs.getString(24));
                   resource.setMobile(rs.getString(25));
                   resource.setPager(rs.getString(26));
                   resource.setStatus(rs.getString(27));     
                   resource.setGender(rs.getString(28));     
                   resource.setBirthDate(rs.getDate(29));
                   resource.setMartialStatus(rs.getString(30));
                   resource.setLanguage(rs.getString(31));
                   resource.setCurrency(rs.getString(32));
                   resource.setPhoto(rs.getString(33));
                   resource.setCreatedBy(rs.getLong(34));
                   resource.setInitials(rs.getString(35));                         
                   resource.setCreatedDate(rs.getDate(36));
                   resource.setUpdatedBy(rs.getLong(37));
                   resource.setUpdatedDate(rs.getDate(38));
                   resource.setFirstName(rs.getString(39));
                   resource.setLastName(rs.getString(40));
                   resource.setMiddleName(rs.getString(41));          
                   con.close();
                   con=null;
                   return resource;
    }//end of class
    plz help me to solve this problem....
    rajkumar

    The JSP wil be converted into a java file and then compiled into a class. If you are using tomcat, the java file will be somewhere in the work folder of your tomcat installation. Find the java file and check the line that is reported in the exception to see where the null-pointer is coming from.

Maybe you are looking for

  • AT NEW  f,  AT END OF f   in an inernal table Loop ?

    I am trying to subtotal an amount in an internal table by KUNAG.  I then want to write this out to the output file. (see code below) When I run this in debug the AT NEW and the AT END OF of are executed for every loop pass even though the KUNAG value

  • Button to copy text to the clipboard

    Reading the document "Javascript for Acrobat API Reference" Page 120: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf the document discusses the execMenuItem command. From all that I have researched it appears I can

  • Maps on Nokia N95

    Hello, I was just wondering(currently waiting for my N95 to arrive) does the phone come with the maps for sat nav already loaded and ready? Cheers, Carl

  • Dual 1.8 PowerPC G5 does not read Tiger Install Disk

    Has anyone else had problems with their Mac not reading the OSX Tiger 10.4 install disks? I just purchased Tiger brand new from Apple, but my Mac Dual 1.8 GHz PowerPC G5 will not even acknowledge the install disk. I currently have OSX 10.3.9 running.

  • Get the string until first space

    hi, can anyone provide an example how to get the string until the first space? i mean if the value is : this is an example how to get only the word "this" (before the very first space) by select? thanks in advance,