Date in jsp

Hi all,
I have a typical problem
our application deals with getting reports from the database.
the user can enter the status code to get the details or can enter
to date and from date to get the reports .
only one is enough to get the reports ..both are not mandatory.
so if the user enters the statsucode the date fields can be kept empty.
by the function in java with interacts with database has a signature like
function(statuscode,todate,from date)
hence if we enter only status code the todate and from date are passed as
null ..hence we get an error
like null pointer exception....................
can u plz suggest me a solution

Well, you could simply check if the date values being passed are null and if yes, then use your default dates.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
(Yes I know it's on JavaRanch but I think it applies everywhere)
----------------------------------------------------------------

Similar Messages

  • How to Hightlight the Data in Jsp Page

    How to Hightlight the Data in Jsp Page,
    I am doing doing search page,based on values given search page those are sent to servlet,in servlet based on some conditions if particuler id i am getting then i am redirecting to Respective jsp page with highlight the data from database..
    Thanks in advance...

    "Highlighting data in JSP sounds strange".
    Without looking at your search specific algorithms I feel you are finally going to display a page (HTML content) to user which contains highlighted text. Highlighting is not directly related to server side language you use (JSP, ASP, PHP etc.). This is purely HTML and CSS. However, server side script (such as JSP) should generate HTML content for getting highlight effect.
    Following HTML shows highlighted text using background-color property on span element.
    <html>
      <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
      </head>
      <body>
          <p style="font-size:1.1em">This is a long paragraph which contains <span style="background-color: yellow;">highlighted text</span> and non highlighted text.</p>
      </body>
    </html>Thanks,
    Mrityunjoy
    Edited by: mrityunjoy on 14 Jun, 2010 3:30 AM

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • Dates in JSP page

    I have some dates fields on JSP page I want to store data in mysql databse. Can someone tell me how I can format dates as I do for other data types in servlet before I send data to add in databse: such as
    For int type data:
    String paymentID = request.getParameter("PaymentID")
    I format it like this for class Payment.
    Payment newPayment(int.parseInt(paymentID)               
    how do i work with date fields this is what I Am trying to do:
    Code patches....
    import java.text.DateFormat;\import java.text.ParseException;
    public date date1;
    try                               
          date1= format.parse(paymentStartDate);
    catch(ParseException pe)
    System.out.println("Problem found");
    ....I do not get any error but it leaves date fields empty because date1 formatting never goes to try... Always say "Problem found on console"
    Any help?

    I just realized I should post the whole file... here is code of the servlet that recieved dates from JSP and process it.
    package admin;
    import java.lang.Object.*;
    import java.text.DateFormat;
    import java.util.Date;
    import java.io.IOException;
    import java.text.ParseException;
    import data.*;
    import business.*;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class AddPaymentServlet extends HttpServlet{
         public Date date1;
         public Date date2;
        public DateFormat format;
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
    // Stores user entered Payment information in variables to create new Payment vector
              String paymentID = request.getParameter("paymentID");
              String clientName = request.getParameter("clientName");
             String paymentType = request.getParameter("paymentType");
              String paymentAmount = request.getParameter("paymentAmount");
             String paymentStartDate = request.getParameter("paymentStartDate");
              String paymentExpiryDate = request.getParameter("paymentExpiryDate");
              String paymentDescription = request.getParameter("paymentDescription");
              String paymentState1 = request.getParameter("paymentState"); // use String type of PaymentType
    //-----------------------------------Format dates----------------------------------------------------------          
             DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.SHORT);
           //    System.out.println("Date1--->"+date1);
                  try
                       {    date1 = format.parse(paymentStartDate);
                        //    System.out.println("Date1--->"+date1);
                     catch(ParseException ps)
                            System.out.println("can't format dates");     
                      try
                       date2 = format.parse(paymentExpiryDate);
                  catch(ParseException pe)
                       System.out.println("can't format dates");
    // get old Payment object from session
    //--------------------------------Send new PAyment Information to Vector Payment in Payment.jave-----------------------------
              Payment newPayment = new Payment(clientName,paymentType,Double.parseDouble(paymentAmount),date1,date2,paymentDescription,paymentState1);
    //------------------------------ Call PaymentDB function Add() to store new payment infomration in the databse
             PaymentDB.addRecord(newPayment);
    // over-write Payment object in session
              request.getSession().setAttribute("payment",newPayment);
              request.getSession().setAttribute("payments",PaymentDB.readRecords());
    //---------------------------------- Send results back to payment.jsp for updated information----------------------
              RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Admin/payments.jsp");
              dispatcher.forward(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              doGet(request, response);
    }

  • Grouping Data with JSP or JSTL

    Hi All,
    I would like to ask a question about how I can group data in JSP. Essentially, I have a DataBean (extends ArrayList) that is being returned to my JSP. The ArrayList contains HashTables. Please note that the JSP assumes the data is returned in sorted order. This JSP is not responsible for sorting the data itself.
    [UPDATED EXAMPLE]
    For example, here is what the data might look like:
    Column A Column B Column C
    1 2 3
    1 15 20
    4 5 6
    4 99 66
    7 8 9
    10 11 12
    Here is how I would use my DataBean:
    String column1Name =bundle.getString(�columnA.title�);
    String column2Name =bundle.getString("columnB.title");
    String column3Name =bundle.getString("columnC.title");
    /* Loop through the bean. */
    for (int i=1;i<myDataBean.size();i++) {
    Hashtable reportRow=myDataBean.get(i);
    String column1Value=reportRow.get(Constants.COLUMNA);
    String column2Value=reportRow.get(Constants.COLUMNB);
    String column3Value=reportRow.get(Constants.COLUMNC);
    }Question
    If I want to change my layout/display to group by a particular column. How would I do that without changing the data structure that is running my current DataBean? Below is an example of grouping by the values in ColumnA.
    ColumnA: 1
    ColumnB ColumnC
    2 3
    15 20
    ColumnA: 4
    ColumnB ColumnC
    5 6
    99 66
    ColumnA: 7
    ColumnB ColumnC
    8 9
    ColumnA: 10
    ColumnB ColumnC
    11 12
    Your help is very much appreciated.
    Thanks!

    Just curious, do people find my question unclear? Can I help clarify any points?

  • Sending binary data from JSP (1.1)

    Hi all:
    I am using Tomcat 3.2.1 and Apache under Linux Mandrake OS.
    I have a JSP (1.1) sending binary data (GIF, PDF, DOC ..) using response.getOutputStream().write(data)
    method.
    The problem is the precompiler automatically creates the JspWriter and puts some out.write("\r\n") lines
    before I use getOutputStream method. The JVM throws an IllegalStateException because I am using both
    methods (this is from Servlet 2.2 specification).
    Must I change my code to forwarding to a servlet that make this work or is there a simple solution to
    avoid this?
    Thanks in advance.
    J.
    null

    Hi Shreeharsha
    Please refer to below docs for sending data from JSP page to RFC. In which you need to use sap connectors for connecting to SAP backend system.
    http://help.sap.com/saphelp_nw04/helpdata/en/b6/55e3952a902447847066a0df27b0d6/content.htm
    Hope it helps
    Regards
    Arun

  • Need help in fetching requested data from JSP

    Hello,
    I really need help in fecthing requested data from JSP to servlet. Can anyone assist me as soon
    as possible because I must finish my program by today.....( 20/02/2002).
    Thanks in advance.

    It is very likely that somebody can help you, if you say what your problem is. In fact somebody might already have helped you. What is your problem?

  • Inserting data from jsp form to multiple tables !

    Hi,
    I want to insert data from jsp form to two tables
    tables are
    (1) Form
    formId (PK)
    deptName
    (2) Data
    formId (FK)
    sNo
    description
    itemCode
    and the problem is that i want to save information form a jsp form to above two tables and i have only one form.
    so how do i insert data from a jsp form to multiple tables.

    You already know what your form in the jsp will be and what fields they are. You also already know what your database looks like. Using one form, you should be able to break the data down, and give it certain ids and/or names, so that when the form is submitted, you retrieve the correct values corresponding to a specific field and insert it.
    Unless there is something else I am not catching, this seems pretty straight forward.

  • Passing data from JSP to Oracle Reports

    Hi,
    We have a requirement to query and display data in JSP pages and when clicked on 'Report' button of the JSP, an Oracle report should be called.
    The data which is queried in JSP should be passed to the Oracle report. Is there any way of doing it? This is to avoid re-querying the database again from Oracle Reports.
    Environment: jdk1.3, Oracle Application Server 9i, Oracle 9i, Report 6i
    Thanks in Advance,
    Srinivas

    You could have the Applet make a request to the server (via URLConnection).

  • Displaying calculated data in JSP pages

    This is a general question about displaying data in JSP pages which has been calculated through ViewObj Routines. I have exposed the methods to the application level however, I want these methods to automatically run on the launch of the page. I can so this with a data action in the struts file. However, I have lots of these methods (all bringing single values of data), it seems inelegant to have 10 data actions or so. What's the best way to expose and show data on a JSP page automatically which has been calculated from the database rows.
    Thanks in advance

    You could convert the vo row to a hash using BeanUtils and then you could do what you want with it programmaticaly to automatically dissplay the lhash values.

  • How to export data in JSP to MS excel

    hi frens..
    anyone out there knows how to export data in JSP to Ms excel .. i already add this code inside my jsp..
    <%@ page contentType="application/vnd.ms-excel" %>i need to retrieve the data from the database to excel.. it's something like a report display in the excel.

    set the response type as....
    response.setContentType("application/vnd.ms-excel");
    U must be geting the data from the database...
    get the data ...
    rs=st.executeQuery(sql);
    where sql is ur query and use it as usual....

  • How can we store xml data using jsp

    hai,
    Can anyone please explain in brief how to store xml data using jsp. Also if possible please explain by specifying the code.
    regards,
    Praveen Vinnakota.

    [email protected] wrote:
    how can we publish Labview data using the web?
    You could use shared variables and publish them to the network or use data sockets.
    Kudos always welcome for helpful posts

  • Binary Data and JSP

    Hi all I have a basic doubt. How does Servlets is preferred technology to generate binary data than JSP? Any limitation in JSP?

    Okay,
    When you write a JSP file, you type it in text, and all the text you type is sent to the client that requests your page. Everything is sent including carriage returns, spaces, tab characters and anything you have type into the file. Only things that are inside <% and %> do not get sent through. If you have several blank lines at the end of the file they will be sent to the client and may cause issues if you are writing binary data that needs to be handled by an application.
    With Servlets you have to write data to the outputstream you get from the (cant quite remember) response.getOutputStream() method. This ensures that only what you want to send gets sent to the client.
    It sepends on what you need it for. If it doesnt matter what you send through then JSP can be used to write binary data. In one application I had to send through sound files to the client and any extra data would only corrupt the sound, so it had to be sent using servlets.
    Does that help?

  • Problem Using HTTP Dispatcher -- Could Not able to get the data in JSP

    Hi, I am using HTTP Dispatcher to send my events to particular URL which is a JSP page. I am trying to populate the received event through URL and populate to a oracle data base. But could not able to get the data in Oracle database.
    Code is :
    <h1>JSP Page</h1>
    <%
    long type = 0;
    String tagId = null;
    String timeStr = "0";
    String deviceName = "";
    // Get Event Parameters
    // Available Parameters: id, siteName, deviceName, data, time, type, subtype, sourceName, correlationId
    try
    type = Long.parseLong(request.getParameter("type")); // Get type
    tagId = request.getParameter("id"); // Get tagId
    timeStr = request.getParameter("time"); // Get time
              deviceName = request.getParameter("deviceName");
    catch (Exception e)
    out.println( "Error: "+e.getMessage() );
              // Write into DB.
              try {
              if ((tagId == null) || (type != 200) ){
                   // Do Nothing
                   //return;
              } else {
                   OracleDataSource ods = new OracleDataSource();
                   String URL = "jdbc:oracle:thin:@//3.235.173.16:1525/vislocal";     
                   ods.setURL(URL);
                   ods.setUser("cus");
                   ods.setPassword("cus");
                   Connection myConn = ods.getConnection();     
                   Statement stmt = myConn.createStatement();
                   String selectQuery =
                             "SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
                        "cus.rfid_raw_reads ";
                   ResultSet rs = stmt.executeQuery(selectQuery);
                   String maxId = "1";
                   if (rs.next()) {
                        maxId = rs.getString(1);               
                   String selectMaxTagIDQuery =
                             "SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
                        "cus.rfid_raw_reads WHERE tag_id = '" + tagId + "'" ;
                   stmt = myConn.createStatement();
                   rs = stmt.executeQuery(selectMaxTagIDQuery);
                   String maxTagId = "1";
                   if (rs.next()) {
                        maxTagId = rs.getString(1);               
                   long primaryKey = 1;
                   long tagKey = 1;
                   try {
                        primaryKey = Long.parseLong(maxId) + 1;
                        tagKey = Long.parseLong(maxTagId) + 1;
                   } catch (Exception e) {
                   long currentTime = System.currentTimeMillis();
                   long updateKey = (tagKey - 1);
                   String updateQuery = " UPDATE cus.rfid_raw_reads SET read_end_time = " + currentTime + " WHERE rfid_raw_reads_id = " + updateKey;
                   Statement updateStmt = myConn.createStatement();
                   updateStmt.execute(updateQuery);     
                   String query =
                        "INSERT INTO cus.rfid_raw_reads (rfid_raw_reads_id, tag_id,device_name,read_start_time) VALUES ("+ primaryKey + ",'" + tagId + "'," + deviceName + "'," + System.currentTimeMillis() + " )" ;
                   Statement insertStmt = myConn.createStatement();
                   insertStmt.execute(query);     
                   myConn.commit();
                   myConn.close();
              } catch (Exception e) {
    %>
    <p>For browser debug:
    <%
    out.println( "Type="+type+" ID="+tagId +" time="+timeStr );
    %>
    Kindly suggest where is the problem...
    Thanks and regards
    Mohammad Nasim Akhtar

    HI Prabhat,
    Thanx for your reply, I worked out and able to receive the data in oracle database, Actually there was some problem in insert Query. Now I have tested the same... and able to edit the same in the Database.....
    But I am facing a new problem, Http Dispatcher in SES console is displaying all the Events generated as well as event in Que but there is no events in the Event Send. I guess it is not able to send the events.....?????
    Event statical is showing like this
    Events Received: 0 (0.00/sec)
    Events Generated: 311 (0.19/sec)
    Events Sent: 2 (0.19/sec)
    Queued Events: 309 (0.19/sec)
    Kindly suggest where is the problem, Is it a JSP problem or OSES end problem.....
    Thanks and regards
    Nasim

  • How to sort the data in JSP using stylesheet sorting?

    Hi, i extracted data out in and display them <%=data%> in the jsp, but how to sort? do i have to provide a drop down list that gives different sorting options, and when user clicks on one option, say sort by title, the collection of results are sorted out on the same jsp page? so all in all, only one jsp page is needed or do i need to create xml files, etc?
    i have no idea how to integrate the xml sorting into the jsp page, even after seeing online help, cos there is no example of a jsp page with sorting to refer to. PLease help, thanks alot!

    im getting the data from beans, but one of the requirements was that i cant use the database to sort and display but i have to use xslt to do the sorting in the jsps, so i have no idea how to do so. possible to give an example? thanks

  • No data in JSP Page

    Hi,
    JDeveloper: 10.1.3.3.0.4157
    Database: Oracle XE 10.2.0.1.0
    Browser: Firefox 2.0.0.14
    I am doing the following steps but the resulting web page displays no data. Any
    help would be appreciated:
    - This is all in JDeveloper...
    - Create an application, 'testapp', using the template [JSP, Struts, ADF BC].
    - On the Model node, create a Business Components Diagram. Rename this to
    'Business Domain Diagram' and put it in the 'testapp.model.businessdomain'
    package.
    - Go to a databse connection, expand Tables and drag a table,
    'SYSTEM_PARAMETERS' on to the diagram. The table has 2 VARCAHR2(100) columns,
    one of which is the primary key. I choose 'Business Component Entity Objects'
    from the 'Create From Database Object' popup.
    - I then right-click on the diagram and select 'Generate/Default Data Model
    Components for Diagram'.
    - I put the objects in the package 'testapp.model.datamodel' and create a new
    application module; 'TestModule'.
    - On the testapp.model.datamodel node, I create another Business Components
    Diagram; 'Data Model Diagram' and, from the same node, drag
    SystemParametersView and TestModule on to this new diagram.
    - I then right-click TestModule and select 'Test', and the Business Components
    Browser pops up allowing me to navigate through the dozen or so rows in the
    table.
    Right now I know that the database connection is all good and my java objects
    can see then.
    - I right-click on the ViewController node and select 'Open Struts Page Flow'.
    From the Components pallet, I drag a 'Data Page' icon on to the
    struts-config.xml diagram and rename it 'TestPage'.
    - I then double-click this icon and accept all the default settings to create
    the page and open it in the page diagrammer.
    - From the 'Data Connection' pallet, I expand TestModuleDataControl' and drag
    SystemParametersView1 on to the page.
    - From the drag options, I choose 'Forms/Read-Only Form' and a form
    containing a table is created. The table is 2x2 and contains bindings for
    the databae table column names and data.
    Now the naughty bit...
    - I click the 'Run' icon, a new tab opens up on Firefox and the page renders -
    i.e. I get a 2x2 HTML Table - but there is no data in it. I can see neither
    the column name labels or the contents of the row. There being no text in
    the table, it has collapsed to 2 very thin rows. I think that I should see
    data from one of the rows in the table and I appreciate that I can't see
    any others because I have not yet added any navigation.
    I would appreciate it if anyone could point at the fatal flaw in this
    procedure.
    Not sure if this helps but below is the log from the embedded OC4J server:
    [Starting OC4J using the following ports: HTTP=8988, RMI=23891, JMS=9227.]
    C:\jdev\jdev\system\oracle.j2ee.10.1.3.41.57\embedded-oc4j\config>
    C:\jdev\jdk\bin\javaw.exe -client -classpath C:\jdev\j2ee\home\oc4j.jar;C:\jdev\jdev\lib\jdev-oc4j-embedded.jar -Xverify:none -XX:MaxPermSize=256m -DcheckForUpdates=adminClientOnly -Doracle.application.environment=development -Doracle.j2ee.dont.use.memory.archive=true -Doracle.j2ee.http.socket.timeout=500 -Doc4j.jms.usePersistenceLockFiles=false oracle.oc4j.loader.boot.BootStrap -config C:\jdev\jdev\system\oracle.j2ee.10.1.3.41.57\embedded-oc4j\config\server.xml
    [waiting for the server to complete its initialization...]
    04-May-2008 09:45:07 com.evermind.server.jms.JMSMessages log
    INFO: JMSServer[]: OC4J JMS server recovering transactions (commit 0) (rollback 0) (prepared 0).
    04-May-2008 09:45:07 com.evermind.server.jms.JMSMessages log
    INFO: JMSServer[]: OC4J JMS server recovering local transactions Queue[jms/Oc4jJmsExceptionQueue].
    Ready message received from Oc4jNotifier.
    Embedded OC4J startup time: 95640 ms.
    08/05/04 09:46:02 Oracle Containers for J2EE 10g (10.1.3.3.0) initialized
    Target URL -- http://10.1.1.2:8988/testapp-ViewController-context-root/TestPage.jsp
    04-May-2008 09:46:55 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
    04-May-2008 09:46:55 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
    04-May-2008 09:46:56 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='testapp.view.ApplicationResources', returnNull=true
    04-May-2008 09:46:57 oracle.adf.share.config.ADFConfigFactory findOrCreateADFConfig
    INFO: oracle.adf.share.config.ADFConfigFactory No META-INF/adf-config.xml found
    04-May-2008 09:47:01 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
    04-May-2008 09:47:01 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
    04-May-2008 09:47:01 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
    04-May-2008 09:47:01 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
    04-May-2008 09:47:01 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
    Thanks in advance.
    Steve

    Hi,
    make sure the Struts action in the Struts diagrammer is selected when pressing the run button. Or select the action and choose run from the context menu
    Frank

Maybe you are looking for

  • When I am on Firefox, my Netzero email page suddenly dropped to very small print. AOL OK. How do I increase size of the print so I can read the email?

    I was using Firefox to read my Netzero email. The print suddenly dropped down to very small and I have difficulty reading the email. Netzero said to oper Mozilla Firefox, click "tools", click "options", and click "content" to change the font to a big

  • Closing balance is not correct in FBL3N

    Hi . I'm facing a problem in fbl3n closing balance on 31dec 2010 . i have taken a balance of 5th dec 2010 of particular gl account in CHF currency which is -421,000.00, now balance from 6th dec to 31 dec of same account in CHF is -67,000.00. So based

  • Need to replace a tag in Request XML in OSB

    I have my proxy service in OSB connected to MQ as the input provider. Now I want to take a couple of namespaces and copy them into the body and remove those tags. Here is the input from MQ... <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.or

  • Dynamic Web Service URL

    I'm using a .Net based web service to fetch data. The exported XCelsius will be deployed on the customer's environment along with the web service. In that case, the SWF file should connect to web service deployed on my customer site. But, it looks fo

  • Automatic Serial no

    one requirement  in my business scenario  like  some material we have batch with serial no  so we assigned serial no profile in  plant level data  my  query is  when i do  goods receipt against purchase order if i select the checkbox create serial no