JSTL Timestamp problem

I want to subtract current Timestamp from other Timestamp which is from Database, but follwing error occured
org.apache.jasper.JasperException: /jstl_online_user.jsp(18,2) The function Timestamp must be used with a prefix when a default namespace is not specified
     org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
     org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
     org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
     org.apache.jasper.compiler.Validator$1FVVisitor.visit(Validator.java:1229)
     org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:122)
     org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:193)
     org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:234)My code
<%@ page import="java.sql.*,javax.sql.*,javax.naming.*"  isELIgnored ="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<sql:query var="rs_online" dataSource="helpdeskJNDIRef">
  Select u.user_id,user_ip,user_timestamp,user_what_action,user_what_arg1,user_name,user_display_name from user u , whos_online w where u.user_id=w.user_id
</sql:query>
<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>
    <h2>Results</h2>
     <c:out value="${1 + 2 + 3}" />
    <c:forEach var="row" items="${rs.rows}">
          Text Message: <c:out value="${i.user_name}"/><br>
          <c:set var="logged" value="${(new java.sql.Timestamp(new java.util.Date().getTime())).getTime() - row.user_timestamp}" scope="page" />
            <c:out value="${logged}" />
    </c:forEach>
  </body>
</html>Edited by: sagar_birari on 7 Jun, 2008 12:02 PM

EL is not a scripting language, just an Expression Language, so you can't create timestamps with it.
You probably shouldn't be doing this logic in the JSP anyway. Try moving the logic to beans. The code might look something like this:
<%@ page isELIgnored ="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- Create a bean then controls getting the user(s) from the database -->
<jsp:useBean id="userLog" class="login.UserLog" scope="request" scope="page">
  <!-- Use a public void setUserName(String) method to set the w.user_id. 
       This method may execute the SQL and store results
  -->
  <jsp:setProperty name="user" property="userName" value="w.user_id"/>
</jsp:useBean>
<!-- Get a List<User> of all the logged in users that match the name given previously.
     If the setUserName method didn't execute the SQL, then the method
     public List getAllUsers(void) method this line calls should.
-->
<c:set var="usersLoggedIn" value="${userLog.allUsers}" scope="page" />
<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>
    <h2>Results</h2>
     <c:out value="${1 + 2 + 3}" />
    <!-- Iterate over the List<User> of users.  Objects in the list are of another bean type (login.User) -->
    <c:forEach var="user" items="${usersLoggedIn}">
          <!-- Call login.User#public String getUserName(void) method -->
          Text Message: <c:out value="${user.userName}"/><br>
          <!-- Call login.User#public String getLoggedTime(void) method which takes the current timestamp
               and subtracts the time the user logged in, and converts it back to a String for display
          -->
            <c:out value="${user.loggedTime}" />
    </c:forEach>
  </body>
</html>Of course, you could try doing the timestamp math in a scriptlet <% ... %> and storing the value in the pageContext.

Similar Messages

  • RSREQDONE TimeStamp Problem

    Dear friends,
    I observed that in Table RSREQDONE the timestamp of fields (TUZEIT,UZEIT) is one hour behind from system time.
    for e.g whenthe DTP load time in RSMO is 09:00 AM then the request load time in table RSREQDONE is 08:00 AM.
    Can any SAP or OSS note solve this timestamp problem or time difference.
    Thank you !!

    Hi,
    All the SAP backend tables will have timestamp in UTC/GMT time zone...i.e German time irrespective of your server time.  This is SAP's Standard functionality
    Thanks,
    SB.

  • Tomcat, jstl, jndi problem

    Hi,
    I've been attempting to use JSTL to print out some info from a JNDI datasource (mysql) that I have created in Tomcat. I am running Tomcat 5.0.27. I have tested the JNDI datasource using this code and it works fine:
    <%
         Context ic = new InitialContext();
         DataSource myDataSource = (DataSource) ic.lookup("java:comp/env/jdbc/helpdesk");
         Connection conn = myDataSource.getConnection();
         if (conn == null)
              out.println("The connection was null");
         else
              out.println("The connection was not null");
         Statement st = conn.createStatement();     
         ResultSet rs = st.executeQuery("SELECT * FROM projecttypes");
         while (rs.next())
              out.print("<br>");
              out.print(rs.getString("typeName"));
              out.print("<br>");
              out.print(rs.getString("typeID"));
              conn.close();
    %>However, when I attempt to access the same datasource via JSTL, the tags seem to render, but it doesn't print any values, just the name of the variable. Here is an example:
    The code:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <sql:query var="rs" dataSource="jdbc/helpdesk">
    select typeID, typeName from projecttypes
    </sql:query>
    <html>
      <head>
        <title>DB Test</title>
      </head>
      <body>
      <h2>Results</h2>
    <c:forEach var="row" items="${rs.rows}">
        ID<c:out value="${row.typeID}"/><br/>
        Name <c:out value="${row.typeName}"/><br/>
    </c:forEach>
      </body>
    </html>Here is the output:
    Results
    ID ${row.typeID}
    Name ${row.typeName}I don't understand what's going on, because when I view the source, the tags look as they have been rendered, but I get no database output. But, when I used the JSP scriptlet I had above, it works fine. Also, here are my web.xml, server.xml, and my context file:
    web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
        "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
         <!-- general application info -->
         <display-name>
              Americas IT Customer Support Website
           </display-name>
           <description>
                Provides helpdesk information and services to Uniqema Americas.
         </description>
         <!-- context parameters -->
         <context-param>
                <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
              <param-value>jdbc/helpdesk</param-value>
         </context-param>
         <!-- servlet info -->
              <!-- standard action servlet configuration (with debugging) -->
           <servlet>
             <servlet-name>action</servlet-name>
             <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
             <init-param>
                    <param-name>config</param-name>
                    <param-value>/WEB-INF/struts-config.xml</param-value>
             </init-param>
             <init-param>
                    <param-name>debug</param-name>
                    <param-value>2</param-value>
             </init-param>
             <init-param>
                    <param-name>detail</param-name>
                    <param-value>2</param-value>
             </init-param>
             <load-on-startup>2</load-on-startup>
           </servlet>
         <!-- servlet mappings -->
              <!-- standard action servlet mapping -->
           <servlet-mapping>
             <servlet-name>action</servlet-name>
             <url-pattern>*.do</url-pattern>
           </servlet-mapping>
         <!-- welcome file list -->
         <welcome-file-list>
              <welcome-file>index.jsp</welcome-file>
              <welcome-file>index.html</welcome-file>
         </welcome-file-list>
         <!-- tld definitions -->
              <!-- struts tag library descriptors -->
           <taglib>
              <taglib-uri>/WEB-INF/tld/struts-bean.tld</taglib-uri>
             <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
           </taglib>
           <taglib>
             <taglib-uri>/WEB-INF/tld/struts-bean.tld</taglib-uri>
             <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
           </taglib>
           <taglib>
             <taglib-uri>/WEB-INF/tld/struts-logic.tld</taglib-uri>
             <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
           </taglib>
           <taglib>
             <taglib-uri>/WEB-INF/tld/struts-nested.tld</taglib-uri>
             <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
           </taglib>
           <taglib>
             <taglib-uri>/WEB-INF/tld/struts-tiles.tld</taglib-uri>
             <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
         </taglib>
    <taglib>
        <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
         <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
         <taglib-location>/WEB-INF/tld/fmt-rt.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
         <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
         <taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
         <taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
         <taglib-location>/WEB-INF/tld/sql-rt.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
         <taglib-location>/WEB-INF/tld/x.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
         <taglib-location>/WEB-INF/tld/x-rt.tld</taglib-location>
      </taglib>
         <!-- error page info -->
         <error-page>
              <error-code>404</error-code>
              <location>/errors/404.jsp</location>
         </error-page>
         <error-page>
              <error-code>500</error-code>
              <location>/errors/500.jsp</location>
         </error-page>
         <error-page>
              <exception-type>java.lang.Exception</exception-type>
              <location>/errors/error.jsp</location>
         </error-page>
         <resource-ref>
          <res-ref-name>jdbc/helpdesk</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
           <res-auth>Container</res-auth>
      </resource-ref>
    </web-app>server.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Server>
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
      <GlobalNamingResources>
        <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
        <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
        <ResourceParams name="UserDatabase">
          <parameter>
            <name>factory</name>
            <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
          </parameter>
          <parameter>
            <name>pathname</name>
            <value>conf/tomcat-users.xml</value>
          </parameter>
        </ResourceParams>
      </GlobalNamingResources>
      <Service name="Catalina">
        <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="80" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
        </Connector>
        <Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
        </Connector>
        <Engine defaultHost="localhost" name="Catalina">
          <Host appBase="webapps" name="localhost">
            <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
          </Host>
          <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
          <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
        </Engine>
      </Service>
    </Server>helpdesk.xml (context file)
    <?xml version='1.0' encoding='utf-8'?>
    <Context crossContext="true" debug="5" displayName="Americas IT Customer Support Website" docBase="D:/projects/helpdesk/web" path="/helpdesk" reloadable="true" workDir="work\Catalina\localhost\helpdesk">
      <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_helpdesk_log." suffix=".txt" timestamp="true"/>
      <Resource name="jdbc/helpdesk"
                   auth="Container"
                   type="javax.sql.DataSource"/>
      <ResourceParams name="jdbc/helpdesk">
        <parameter>
          <name>factory</name>
          <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>
        <!-- Maximum number of dB connections in pool. Make sure you
             configure your mysqld max_connections large enough to handle
             all of your db connections. Set to 0 for no limit.
             -->
        <parameter>
          <name>maxActive</name>
          <value>100</value>
        </parameter>
        <!-- Maximum number of idle dB connections to retain in pool.
             Set to 0 for no limit.
             -->
        <parameter>
          <name>maxIdle</name>
          <value>30</value>
        </parameter>
        <!-- Maximum time to wait for a dB connection to become available
             in ms, in this example 10 seconds. An Exception is thrown if
             this timeout is exceeded.  Set to -1 to wait indefinitely.
             -->
        <parameter>
          <name>maxWait</name>
          <value>10000</value>
        </parameter>
        <!-- MySQL dB username and password for dB connections  -->
        <parameter>
         <name>username</name>
         <value>helpdesk</value>
        </parameter>
        <parameter>
         <name>password</name>
         <value>helpdesk</value>
        </parameter>
        <!-- Class name for the old mm.mysql JDBC driver - uncomment this entry and comment next
             if you want to use this driver - we recommend using Connector/J though
        <parameter>
           <name>driverClassName</name>
           <value>org.gjt.mm.mysql.Driver</value>
        </parameter>
         -->
        <!-- Class name for the official MySQL Connector/J driver -->
        <parameter>
           <name>driverClassName</name>
           <value>com.mysql.jdbc.Driver</value>
        </parameter>
        <!-- The JDBC connection url for connecting to your MySQL dB.
             The autoReconnect=true argument to the url makes sure that the
             mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
             connection.  mysqld by default closes idle connections after 8 hours.
             -->
        <parameter>
          <name>url</name>
          <value>jdbc:mysql://webdev:3306/helpdesk?autoReconnect=true</value>
        </parameter>
      </ResourceParams>
    </Context>Ok, I think that's all. Thanks in advance.

    The problem is that your EL is being ignored. This is caused by using an out-of-date web.xml DTD. Your web.xml begins like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
        "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>Giving you the 2.2 version of the web app. You want 2.4 (newest version) which you get by doing this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                                 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
             version="2.4">to your web.xml
    (No doctype, that long tag is the web-app tag)

  • PDF signature timestamp problem

    Hi, sorry if this post is slightly offtopic.
    We are trying to sign and timestamp pdf documents in java (using Apache PDFBox) and we are stuck with a problem for more than a week. The signature itself is good, Adobe Reader can validate it succesfully (after adding our self signed test root certificate to trusted certificates). The problem is with the timestamp. Adobe Reader says that the signature is timestamped, but the timestamp could not be verified. If I look at the Date/Time tab on the Signature Properties window the Timestamp Authority field says Not available. Older versions of Adobe Reader 9 displayed the Show Certificate button for the Timestamp Authority as enabled, and if I clicked it, the Reader crashed. In newer Reader 9 versions and in Reader X the button is disabled. It seems Reader recognises the timestamp but can't extract the TSA certificate.
    However if I sign the pdf with Acrobat X Pro or with iText (using the same private key and the same TSA) everything is perfect, the timestamp is validated, Timestamp Authority field shows the correct value, TSA certifiicate is OK.
    I analyzed the signatures and the timestamp tokens, but I could not find any significant difference between the good and wrong ones.
    I wanted to attach a working and a non-working sample but I didn't find how to do that.
    Could someone please give us some advice about what could cause something like this?
    Can Reader log the signature parsing/validating process to view what's wrong?
    Thanks in advance
    Csaba

    Hi,
    I had the same problem with the pdf signature timestamp…..
    The thing I was doing wrong was the SHA-1 hash sent to the timestamp server, more precisely I was sending the whole signature SHA-1 hash when I suppose to send the SHA-1 hash of the RSA encrypted hash of the digital signature (I think that in your case is the 256 hash starting from 1783).
    Hope this helps you,
    Corina

  • [iOS4] CMDeviceMotion and timestamp problem

    Hi,
    Excuse my English as it isn't my primary language.
    I hava a problem using an instance of CMDeviceMotion. I need data from both the gyro and accelerometer and the frequency of sample is set at the maximum, 100.
    I also need the timestamp at which the sample was taken. However, at the beginning the timestamp doesn't change even if the acceleration and gyro change. I got something like that :
    0.003779 -0.050910 0.001185 933.604339
    0.035029 -0.042457 0.019893 933.604339
    0.062266 -0.009147 0.084819 933.604339
    0.069300 0.012292 0.092631 933.604339
    0.047862 0.018517 0.091456 933.604339
    0.035304 0.029885 0.084575 933.604339
    0.032496 0.039498 0.083583 933.604339
    We have acceleration.x, .y, .z and the timestamp. As you can see the timestamp doesn't change for about 60 upgrades ~6 seconds.
    Besides, when it finally starts upgrading, it sometimes sample twice the accelreation/gyro at the same timestamp :
    0.115215 0.005342 -0.051157 1385.964002
    *0.120561 0.019797 -0.054112 1385.977830*
    *0.122637 0.031470 -0.051182 1385.977830*
    0.113840 0.042271 -0.045493 1385.992829
    Here is my code :
    In the viewDidLoad method :
    motionManager = [[CMMotionManager alloc] init];
    motionManager.deviceMotionUpdateInterval = 0.01;
    frequence = 100;
    Then I have a method invoked by a button :
    [motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]
    withHandler: ^(CMDeviceMotion *motionData, NSError *error)
    CMRotationRate rotation = motionData.rotationRate;
    CMAcceleration acceleration = motionData.userAcceleration;
    NSLog(@"rotation rate = [%f, %f, %f, %f]", rotation.x, rotation.y, rotation.z, motionData.timestamp);
    NSLog(@"acceleration rate = [%f, %f, %f, %f]", acceleration.x, acceleration.y, acceleration.z, motionData.timestamp);
    Any help appreciated,
    Thanks for your time
    Loïs

    Oracle FAQ page: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#08_01
    Well obviously that was really stupid.
    I'm adding some queries to an older part of our code base and while reading through the documentation for one of the classes I found that we weren't using our normal Hibernate queries because we needed to ensure that we weren't sending Timestamps to Oracle. Apparently the Timestamp would be converted to a Date because the column in the database was of type DATE. This was causing problems because the DATE column's index was being ignored and the table contains millions of records.
    Not sure I follow that logic.
    If the value was going into the database then it would update the index.
    From that only one of the following could be true.
    1. It wasn't going into the database.
    2. It was being truncated to a date.
    The Oracle FAQ seems to indicate that this has been fixed in the 11.1 JDBC drivers. I know that I can use 11.1 JDBC drivers with a 10.2.0 database, but will it use the new 11.1 mappings for DATE and TIMESTAMP or the old 10.2.0 mappings? I would agree with your interpretation of the FAQ.
    And I would then follow it up by testing both with the old driver and the new.

  • SQLServer date / timestamp problems ?

    Hi,
    I am having trouble reading a timestamp field from sql server. Java 1.3/SQLServer 7 SP1, ODBC:JDBC bridge
    We can access other datatypes OK but get the error
    [Microsoft][ODBC SQL Server Driver]Restricted data type attribute violation
    when we try to read a timestamp or datetime value, using getTimestamp or getDate.
    Can anyone explain this error ?
    java.sql.Date myDate;
    java.sql.Timestamp myTimestamp;
    java.util.Calendar cal = java.util.Calendar.getInstance();
    java.util.TimeZone tz = java.util.TimeZone.getTimeZone("GMT");
    String d;
    try{
    myTimestamp = r.getTimestamp("fldDate", cal);
    System.out.println("Got timestamp");
    System.out.println("timestamp is "+myTimestamp.toString() );
    catch( SQLException e) {
    System.out.println("Timestamp failed"+e);
    try{
    myDate = r.getDate("fldDate");
    d=myDate.toString();
    System.out.println("Date :"+d);
    catch( SQLException e) {
    System.out.println("Date failed"+e);

    You can fix your problem with SQLServer timestamps simply making a minor change.
    SQLServer timestamps are, in fact Binary big integers. So, for example if you have a Country table and you select it as:
    Select
         [CountryID],
         [Name],
         user_name([InsertUser]) AS InsertUser,
         [InsertDate],
         user_name([ModifyUser]) AS ModifyUser,
         [ModifyDate],
         ts
    From     Country
    Order By [CountryID]
    Then you will get a problem because Java timestamp are Dates types. To fix the problem, just add a Convert function, like this:
    Select
         [CountryID],
         [Name],
         user_name([InsertUser]) AS InsertUser,
         [InsertDate],
         user_name([ModifyUser]) AS ModifyUser,
         [ModifyDate],
         Convert(bigint, [ts]) AS ts
    From     Country
    Order By [CountryID]
    And finally, from your Java code, read this column as a BigInt.
    RDC

  • Timestamp problem with Toplink9.0.3 and OC4J 9.0.3,9.0.4

    Hello,
    we use Toplink 9.0.3 as OR tool in our application deployed in OC4J 9.0.3 or 9.0.4. In both containers we have a problem with java.sql.Timestamp attributes of objects - when an object is fetched from DB (Oracle 9i) the time portion is always cleared. So we see only the date portion of timestamp. Timestamps are correct in database.
    We tried one workaround in 9.0.3: we replaced oc4j\jdbc\lib\classes12dms.jar with ojdbc14.jar taken from Oracle9i DB. This worked for us but we had deadlock problems (I've already posted it here some days ago) - I actually don't know if the problems were caused by this workaround or not...
    Thanks for replies.
    Marcel

    Marcel,
    Like I said, OC4J supports JDK 1.3 only (by default). Therefore, the "classes12dms.jar" driver is also only compatible with JDK 1.3. As far as I know, there is no problem associated with replacing "classes12dms.jar" with "ojdbc14.jar", but I think you also need to configure OC4J to work with JDK 1.4 -- and it's not clear to me from your postings, whether you have done that (or not).
    There was a recent post in these forums that referred to the product compatibility matrix that is available from Oracle's MetaLink Web site. Have you checked your Oracle product combination against it?
    Good Luck,
    Avi.

  • JSTL if - problem

    Hello. I have the following problem. I have a website where sometimes users register or they just login. When the user register, the first line of my code gets his ID. But when the user is already registered and just login, the first line returns null. But then, when they login, I add the 'user' session attribute, which contains his ID.
    Here in my code, I checked that when remoteUser return 'null', the <c:if test> is not working. It never reaches session.user. Any ideas?
    <c:set var="us" value="${pageContext.request.remoteUser}"/>
    <c:if test="${us == 'null'}">
    <c:set var="us" value="${session.user}"/>
    </c:if>
    <sql:query var="rs" dataSource="jdbc/agenda">
    SELECT * FROM cards WHERE username="${us}"
    </sql:query>Is it possible to check when "rs" returns null or empty? if "us" is null, what should I expect from "rs"? Cause then I could check it and repeat the <sql> when necessary.
    Thanks in advance =)

    You're comparing it against the string value "null" instead of the literal null. Remove the quotes, so: ${us == null}. Alternatively you can also use the empty keyword: ${empty us}. Further on, the ResultSet is never null. It can only contain no records or at least one record.
    That said, the JSTL SQL taglibrary is intented for quick test and prototyping only. It is not intented for production applications. You need a servlet and a DAO class to exchange data between JSP and the database. Lookup the DAO pattern.

  • Tomcat 4.0.x and JSP / JSTL performance problems.

    Hello everyone,
    I've got a web application where some of my JSP pages are rendering quite slowly. As an example I'll use a JSP page that I wrote for browsing through a user database. It uses two beans...
    1. jobBean - Ensures that all of the required (and correct) beans that will be used for processing the request have been loaded.
    2. browserBean - A basic JavaBean that holds a set of UserBean(s) and other information pertinent to database queries (start, limit, order).
    I'm using Apache Struts to map requests to the appropriate processing modules. Now the problem I'm having is that each request is taking between 1 and 2 seconds to execute. As you can imagine that's not going to allow for very many simaltaneous users. I've tracked the problem down to something JSP related. All of my code executes fairly quickly (I think). It takes about 20-30ms for my code to identify the request, load the requested data from the database, and convert it into a usable format (the browserBean). Here's my code...
    <%@ page contentType="text/html"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <META http-equiv="Cache-Control" content="no-cache">
    <title>
    Browse Users
    </title>
    </head>
    <body>
    <!-- Set up the OrganizationBeans for use -->
    <jsp:useBean id="jobBean" class="com.vacode.jobs.generic.JobBean" scope="session" />
    <jsp:useBean id="browserBean" class="com.vacode.mqdb.beansets.user.UserBrowserBean" scope="session" />
    <!---------------------------->
    <!-- Start Time Logged Here -->
    <!---------------------------->
    <c:if test="${jobBean.currentJob.name != 'BrowseUserJob'}">
         <!-- This page was accessed before everything was properly initialized -->
         <c:url var="browseUser" value="manageUsers.do">
              <c:param name="action" value="browse" />
         </c:url>
         <c:redirect url="${browseUser}" />
    </c:if>
    <form action="manageUsers.do" method="get">
         <input type="hidden" name="action" value="browse">
         <input type="hidden" name="start" value="<c:out value="${browserBean.dummyStart}" />">
         <input type="hidden" name="order" value="<c:out value="${browserBean.order}" />">
         I would like to view
         <select name="limit">
              <c:forEach begin="1" end="5" var="current">
                   <option value="<c:out value="${current*5}" />"
                        <c:if test="${browserBean.dummyLimit == current*5}">
                        selected
                        </c:if>
                   >
                    <c:out value="${current*5}" />
                   </option>
              </c:forEach>
         </select>
         results per page.
         <input type="submit" action="submit">
    </form>
    <c:url var="id" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_ID" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="name" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="firstName" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_FIRST_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="lastName" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_LAST_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="email" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_EMAIL_ADDRESS" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="organization" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_ORGANIZATION_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="status" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="USER_STATUS_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <c:url var="role" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="0" />
         <c:param name="order" value="ROLE_NAME" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
    </c:url>
    <table>
         <tr>
              <td><a href="<c:out value="${id}" />">Id</a></td>
              <td><a href="<c:out value="${name}" />">User Name</a></td>
              <td><a href="<c:out value="${firstName}" />">First Name</a></td>
              <td><a href="<c:out value="${lastName}" />">Last Name</a></td>
              <td><a href="<c:out value="${email}" />">E-Mail</a></td>
              <td><a href="<c:out value="${organization}" />">Organization</a></td>
              <td><a href="<c:out value="${status}" />">Status</a></td>
              <td><a href="<c:out value="${role}" />">User Type</a></td>
         </tr>
    <c:forEach items="${browserBean.beans}" var="bean">
         <tr>
              <c:url var="manage" value="manageUsers.do">
                   <c:param name="action" value="modify" />
                   <c:param name="beanId" value="${bean.userId}" />
              </c:url>
              <td><a href="<c:out value="${manage}" />"><c:out value="${bean.userId}" /></a></td>
              <td><c:out value="${bean.userName}" /></td>
              <td><c:out value="${bean.firstName}" /></td>
              <td><c:out value="${bean.firstName}" /></td>
              <td><c:out value="${bean.email}" /></td>
              <td><c:out value="${bean.organizationName}" /></td>
              <td><c:out value="${bean.statusName}" /></td>
              <td><c:out value="${bean.roleName}" /></td>
         </tr>
    </c:forEach>
    <!-------------------------->
    <!-- End Time Logged Here -->
    <!-------------------------->
    </table>
    <c:url var="next" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="${browserBean.nextPageStart}" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
         <c:param name="order" value="${browserBean.order}" />
    </c:url>
    <c:url var="previous" value="manageUsers.do">
         <c:param name="action" value="browse" />
         <c:param name="start" value="${browserBean.previousPageStart}" />
         <c:param name="limit" value="${browserBean.dummyLimit}" />
         <c:param name="order" value="${browserBean.order}" />
    </c:url>
    <c:if test="${browserBean.previousPageStart>-1}">
         <a href="<c:out value="${previous}" escapeXml="false" />">previous</a>
    </c:if>
    <c:if test="${browserBean.nextPageStart>-1}">
         <a href="<c:out value="${next}" escapeXml="false" />">next</a>
    </c:if>
    <br>
    <br>
    Quick Jump To Page:
    <c:forEach varStatus="loopTag" items="${browserBean.pageStartValues}" var="current">
    <c:choose>
         <c:when test="${loopTag.index+1==browserBean.currentPageNumber}">
              <c:out value="${loopTag.index+1}" />
         </c:when>
         <c:otherwise>
         <c:url var="thisPage" value="manageUsers.do">
              <c:param name="action" value="browse" />
              <c:param name="start" value="${current}" />
              <c:param name="limit" value="${browserBean.dummyLimit}" />
              <c:param name="order" value="${browserBean.order}" />
         </c:url>
         <a href="<c:out value="${thisPage}" />"><c:out value="${loopTag.index+1}" /></a>
         </c:otherwise>
    </c:choose>
    </c:forEach>
    <br>
    <br>
    Max Possible Pages: <c:out value="${browserBean.maxNumberOfPages}" />
    <br>
    Current Page: <c:out value="${browserBean.currentPageNumber}" />
    </body>
    </html>I've added comments where I timed my code from (by writing new Date().getTime() to the console). It usually takes between 1 and 2 seconds for that block of JSP to execute. I wrote a test class that should be very similar to the process (iterating over the forEach loop mainly) and it usually executed in 10ms to 20ms.
    I had a look at the servlets that were generated by Tomcat and I noticed that for each <c:url> I used there's about 300 lines of code (with several syncronized() methods). Could this have anything to do with it? If so, what could I do to improve the performance?
    Worth mentioning... The machine I am using is an AMD Athlon 1GHZ with 768MB RAM, 7200 RPM UDMA100 IDE HDD.
    I'm also using Tomcat integrated with a development environment (IntelliJ IDEA).
    Any help that anyone could offer is much appreciated.
    Thanks,
    Ryan

    Can you get acceptable performance if you hack out everything except the browserBean forEach loop? Maybe you are trying to do too much runtime EL evaluation on the page.
    If performance improves, you may want to push the URL construction and startValue computations to a Struts Action and put a bunch of objects on the requestScope (like "id_url", "name_url", "pageStartValue").
    Putting these computations in the Action would avoid having JSTL parse each of the ${} arguments, evaluating the expressions, and using costly reflection to turn ${browserBean.order} into browserBean.getOrder().

  • DATE and TIMESTAMP problem - fixable with 11.1 JDBC Driver?

    I'm adding some queries to an older part of our code base and while reading through the documentation for one of the classes I found that we weren't using our normal Hibernate queries because we needed to ensure that we weren't sending Timestamps to Oracle. Apparently the Timestamp would be converted to a Date because the column in the database was of type DATE. This was causing problems because the DATE column's index was being ignored and the table contains millions of records.
    The Oracle FAQ seems to indicate that this has been fixed in the 11.1 JDBC drivers. I know that I can use 11.1 JDBC drivers with a 10.2.0 database, but will it use the new 11.1 mappings for DATE and TIMESTAMP or the old 10.2.0 mappings? Oracle FAQ page: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#08_01

    Oracle FAQ page: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#08_01
    Well obviously that was really stupid.
    I'm adding some queries to an older part of our code base and while reading through the documentation for one of the classes I found that we weren't using our normal Hibernate queries because we needed to ensure that we weren't sending Timestamps to Oracle. Apparently the Timestamp would be converted to a Date because the column in the database was of type DATE. This was causing problems because the DATE column's index was being ignored and the table contains millions of records.
    Not sure I follow that logic.
    If the value was going into the database then it would update the index.
    From that only one of the following could be true.
    1. It wasn't going into the database.
    2. It was being truncated to a date.
    The Oracle FAQ seems to indicate that this has been fixed in the 11.1 JDBC drivers. I know that I can use 11.1 JDBC drivers with a 10.2.0 database, but will it use the new 11.1 mappings for DATE and TIMESTAMP or the old 10.2.0 mappings? I would agree with your interpretation of the FAQ.
    And I would then follow it up by testing both with the old driver and the new.

  • Timestamp problem in Forms 10g

    In a 10g form (using 10g database, running on MS-W2000, Linux-Redhat)
    Record 1 is entered and saved at 12-JAN-2006 13:20:49.
    Record 2 is entered and saved at 12-JAN-2006 13:21:25.
    Then, these 2 records have the timestamp reversed upon retrieval:
    Record 2 12-JAN-2006 13:20:49.
    Record 1 12-JAN-2006 13:21:25.
    How can this happen? Any idea or suggestions? Please help.

    The date item property was defined as:
    data type: datetime
    maxium length:17
    initial value: $$DATETIME$$
    format mask: DD-MON-YYYY HH24:MI
    changed to ->
    data type: datetime
    maxium length:30
    initial value: $$DATETIME$$
    format mask: DD-MON-YYYY HH24:MI:SS
    It still does the timestamp switching for the record 1 and 2. If the record 1 and 2 are inserted more than a minute apart, then it works. Anything to do with database datetime setup?

  • Whatsapp last seen timestamp problem

    I turned off the "last seen timestamp" and I can't turn it back on(I've waited more than 24 hours and still it says that I need to wait 24 hours) I've tried changing the calendar a few days further and it telling me cannot connect to whatsapp service

    Hey, even i went through the same situation, tried uninstalling and reinstalling back, tried all possible solution as been posted here, nothing seems to be working out.
    Finally i have deleted ma account and singed up again. It worked, the only sad part if u will loose all u r chat history. ITS WORKING.

  • Timestamp problem or bug.

    I created a field in an entity using Timestamp as data type.
    When I assign the value I see milliseconds.
    However into the Database I don't see them and it seem to strip them somewhere.
    Looking the constructor (I simply exended Timestamp) I see a value with .0 in millisecond fields.
    How can I solve it ?
    TIA
    Tullio

    Hi all,
    Like all of u, i had this experience and i got some workarounds that work in my situation...
    Let's try this
    _ Open the Entity Object Editor of ur Entity which has the date column.
    _ Choose ur date column name in the Attributes tree node.
    For inserting time: Look on the Entity Attribute tab
    _ Choose Timestamp type for ur column.
    _ Check the option History Column and choose modified on (or created on, depends on ur case).
    For display time: Look on the Control Hints tab
    _ Choose Simple Date for Format Type option.
    _ Use dd-MM-yyyy hh:mm:ss as Format option.
    I use JDeveloper 9.0.4 preview for Windows.
    Hope that help
    VHL.

  • Timestamp Problem

    How can I changed the starting timestamp to skip over the Perticular rec. load to Some data targert
    Thanks in Advance

    Hi,
    Please try replicating the data source to your system again, after that open the corresponding infosource and activate it again.
    By doing this, the previous time stamp will get overcome by the new time stamp without effecting your previous loadings.
    Regards,
    Neha

  • JSTL XML problem

    I use Tomcat 5.5.4, Jarkata JSTL 1.1.2, here is what I do:
    (1) copy JSTL jar (standard.jar, jstl.jar) to tomcat common/lib directory
    (2) create a jsp page like:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <c:import var="data" url="sample.xml" />
    <x:parse var="res" doc="${data}" />
    if I print ${data}, it is correct XML file as I expected. But I always get [document:null] as XML parsing result.
    Besides, whatever JSTL XML function I try, seems all of them give me error or null result.
    Is there any special setting that I miss?
    Why JSTL:core works and JSTL:xml doesn't?
    Anyone have suggestion? Thanks!

    To answer your questions from the previous post: No, I don't have Xalan.jar anywhere, unless it is packaged inside of some other jar, like one of the commons jars.
    I am using Tomcat 5.0.29 or real close to it. Java 1.4.2.
    A further question:
    Do I really need copy c.tld and x.tld to WEB-INF/ and
    set them up in WEB-INF/web.xml?
    No. The tlds inside the JARs are all you need. I would get rid of these copies.
    My understanding is: since you specify that uri:
    http://java.sun.com/jsp/jstl/core, there is no need
    to copy and set-up tld.
    At least, if I remove them, JSTL:core works fine. As
    for JSTL:xml, it doesn't work either way.What version of the web descriptor are you using? Version 2.3 or 2.4? It should either be defined is a <?DOCTYPE... ?> tag (v 2.3) or in the <web-app ...> tag (v. 2.4). You should be using the vs. 2.4.
    I don't know if that would make a difference though...

Maybe you are looking for