Tips for implementing Java code within a JSP <c:if> statement

How can I utilize the "ft" value in a c:if statement?

    <% Date dNow = new Date( );
   SimpleDateFormat ft = 
   new SimpleDateFormat ("yyyy.MM.dd hh:mm:ss a zzz");
   out.print( "<h2 align=\"center\">" + ft.format(dNow) + "</h2>");%>

This is my approach to including code in JSP(sample code)

<c:if test="${row.RecvDate}-$(ft) > 48"></c:if> .....

Description of my objective: I am required to subtract two dates and determine if the result is over 48 hours. If it is, the row should be highlighted in green, otherwise no change.

I extract values from a database and implement validation on the JSP page to highlight rows based on the given condition.

Answer №1

transform your date into an integer, perform subtraction operations, and create custom comparisons

 int convertedDate = (int) (new Date().getTime());
        System.out.println("Converted to Integer : " + convertedDate);
        System.out.println("Long date in Milliseconds: "+ new Date().getTime());
        System.out.println("Converted back to Date object : " + new Date(new Date().getTime()));


    Converted to Integer : 1345619256
    Long date in Milliseconds: 1345619256308
    Converted back to Date object : Wed Aug 22 16:37:36 CST 2012

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The CSS Custom Properties for the IonInput component failed to apply to the helper text

I have encountered an issue with CSS Custom Properties not affecting the helper text. Despite trying to change the color of the helper text, it remained unchanged. Is there a workaround or method to define Custom Properties specifically for helper text? Th ...

Selenium Webdriver is having trouble locating an element within an xblock

As a beginner in Python, Selenium, and coding in general, I'm not sure if my question even makes sense. My current project involves automating the task of saving edX course webpages as HTML. I am using the latest iPython and Webdriver for this purpos ...

I've been struggling with a particularly challenging Visa Interview Question for some time now

I have been struggling with this particular interview question and have yet to find a solution. Your assistance would be greatly appreciated. Question: In a certain area, there are multiple factories emitting a pollutive gas. To reduce pollution, filters ...

In search of advice on the best web-based database management technology

I'm looking to create a prototype for a web-based database manager, similar to the desktop version in the image below, with specific features in mind. Initially, the schema will be provided through a flat file. Considering HTML5 as an option, I am a ...

Tips for adjusting the size of an SVG using percentages

I have multiple tables with data in them, each sized using percentage and resizable. I want to add SVG images to each table without affecting the table size. When I tried setting the sizing like this: <svg xmlns="http://www.w3.org/2000/svg" xml:space=" ...

Choosing between setting a height of 100vh versus a minimum height of 100vh

In the development of my app, I noticed an interesting issue. When I set the background on the html with a height of 100vh and resize the viewport to cause vertical overflow, the background does not cover the overflowed content: html { height ...

dimensions of an element in percentage using css and html, accompanied by some peculiar attributes

I encountered an issue with some CSS and HTML code. The code works perfectly fine in Chrome and Firefox browsers, but when I try to inspect it using developer tools on mobile view, the min-height:100%; property does not seem to be applied. I have attache ...

Guide to adding a new entry to a database table using ajax

At the moment, I have a webpage displaying a grid of employee photos. Each employee has both an IN and OUT photo, named firstname_here.jpg and firstname_away.jpg respectively. By clicking on a photo, it toggles between the two images. Our setup consists ...

Drawer in Material-UI has whitespace remaining at the corners due to its rounded edges

While using the Material UI drawer, I attempted to round the corners using CSS: style={{ borderRadius: "25px", backgroundColor: "red", overflow: "hidden", padding: "300px" }} Although it somewhat works, the corners appear white instea ...

In JavaScript, the array is being passed as "undefined"

<html> <head> <script> function replaceLocation() { var locationArray= new Array(); locationArray[1,2,3,4]=document.getElementById("From").value.split(" "); document.getElementById("map").src="https://maps.google.com/maps?f=d& ...

Invoking a JavaScript function using C# code-behind

The geodata API provides a comprehensive list of countries, states, and cities around the world through three separate select Lists. These select Lists cannot be server-side and may take some time to load all the options. I am looking to preselect a speci ...

Developing a dynamic row that automatically scrolls horizontally

What is the best method for creating a div box containing content that automatically slides to the next one, as shown by the arrows in the picture? I know I may need jquery for this, but I'm curious if there's an alternative approach. oi62.tinyp ...

The fixed div is always positioned in the top corner

My webpage has a 'Book Now' button that remains at the top of the viewport with a 10px gap. However, due to the parent element having a height of 100%, the button scrolls out of view once the viewport surpasses that height. To see an example, cli ...

Exploring Nested CSS Grids and Resizing Images on the Web

Having an issue resizing images in CSS Grid. I set up a main layout with 2 columns, and within the first column is another grid where I intended to place an image and some text. Please remove the html comment so you can see the image. The problem lies i ...

Having trouble with submitting the jQuery form

I have written a script to submit a form after validation and receive the values in a PHP file using $_POST. However, I am not able to retrieve the values in the PHP file. When I try to echo the values, it shows up as blank. Can someone please guide me a ...

Different methods to retrieve content within a div that is located on a separate, included page

It's a bit tricky to come up with a title for this topic, but essentially, I'm trying to figure out how to get content from an included page into a specific div using HTML and PHP. Let me break it down: In the header.php file, we have the follo ...

Is the absolute positioned element on the left or right based on its current location?

Is there a way to assign absolute positioning with left at 0px or right at 0px depending on whether the positioned div will go outside of its container? For example, when you right click in a browser and see the menu appear to the right of where you click ...

Guide on how to retrieve a file through headless Selenium WebDriver without GUI

I am currently facing an issue with downloading files using a headless web browser in Java. Initially, I tried HtmlUnit but faced difficulties when the file download was triggered by Ajax requests. Instead, I switched to Selenium and tested both the HtmlUn ...

What is the best way to design a group of radio buttons with corresponding labels at the top

I'm looking to create a structure like this in HTML: https://i.sstatic.net/wLcZs.png Does anyone know how I can achieve this layout so that the labels are aligned properly with the radio buttons? My main challenge is getting the horizontal labels ab ...

Webix UI - Struggling to create dynamically responsive components during screen resizing

Can anyone guide me on how to make my Webix UI control responsive in the free version available at ? It seems to be acting unpredictably due to the AngularJS integration code I'm using. I have attempted various solutions like media queries, redraw, a ...