How to get current time in jsp page?
my problem is :-
i have a radio buttons with name as 9am, 11am ,1pm, 3pm , 5pm , 7pm , 9pm , 11pm , 1am , 3am ,5am 7am. what ever the current time may be the radio button of four hour plus than current time should be atomatically checked and previous radio buttons should be disabled. for example suppose current time is 11.02am than the radio button of 3pm should be automatically checked and previous radio buttons should be disabled.
please help me if u can?
This should work but it needs testing out around midnight ( not sure if it is 00:00 or 24:00):
<%@ page import="java.util.*" %>
<html>
<head><title>Time Page</title>
</head>
<body>
<% Calendar c = Calendar.getInstance();
c.add(Calendar.HOUR_OF_DAY, 4);
int h = c.get(Calendar.HOUR_OF_DAY); %>
The current hour is <%= h %><br>
<% for (int i=0; i < 24; i++) { %>
<input type=radio name=time <%= (i < h) ? "disabled" : ""%><%= (i == h) ? "checked" : ""%>><%= (i < 10) ? "0" : ""%><%= i %>:00<br>
<% } %>
</body>
</html>
Similar Messages
-
How to get current time and date??
How to get current time and date from my PC time and date to the java application??
i use java.util.* package but got error, that is:
- java.util.* and java.sql.* class are match
- abstract class cannot be instantiated
so what can i do, pls guide...thanks...There is a method in the System class that will return the current system time. You could also instantiate a Date, Time, Timestamp, or Calendar object, all of which get created with the system time by default.
Don't import *. Import the specific classes you need.
Next time, post the actual text of the exceptions/compile errors. If you make people guess, most just won't bother. -
How to get multiple selections from jsp page in my servlet
Hello Everyone,
I've a list that allows users to make multiple selections.
<select name=location multiple="multiple">
<option>
All
</option>
<option>
Hyd
</option>
<option>
Dub
</option>
<option>
Mtv
</option>
</select>I want to get the selections made by user in jsp page from my servlet, selections can be multiple too.
ArrayList locList = new ArrayList();
locList = request.getParameter("location");when I do so, I get compilation error as the request returns string type. How do I then get multiple selections made by the user.
Please let me know.For those kind of basic questions it would help a lot if you just gently consult the javadocs and tutorials.
HttpServletRequest API: [http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html]
Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
Coreservlet tutorials: [http://courses.coreservlets.com/Course-Materials/] -
How to get ep authority in jsp page
Hi all:
I want to create a j2ee project and some jsp pages to deploy to EP server.
My question is how to get user name or user authority in jsp page.
Is there any APIs to use or something else.
Thanks in advance.
AllenHai ,
I Think This will help ful for u check it ,
File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10, new TraceFormatter());
The above code specifies the path for your log file.
Then add this file as a log location and then log the traces. For this you can use the following code like:
Location location=Location.getLocation(className);
location.addLog(file);
location.setEffectiveSeverity(Severity.ALL);
location.entering(methodName);
To Create j2ee apllication
In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
So as you are using this in Portal Application, this does not work.
You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
In this Web Module Project, try creating JSP, this will work.
So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
Regards ,
venkat -
How to get table headers in jsp page
hi,
this is praveen, can any one help me to solve this problem.
how to get table headers in a jsp page. whether it is possible using javascript or is there any other way.
pls send rep.
thank u.Hai ,
I Think This will help ful for u check it ,
File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10, new TraceFormatter());
The above code specifies the path for your log file.
Then add this file as a log location and then log the traces. For this you can use the following code like:
Location location=Location.getLocation(className);
location.addLog(file);
location.setEffectiveSeverity(Severity.ALL);
location.entering(methodName);
To Create j2ee apllication
In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
So as you are using this in Portal Application, this does not work.
You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
In this Web Module Project, try creating JSP, this will work.
So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
Regards ,
venkat -
How to get Tree structure in JSP page?
Hi,
I would like get data from the database and display the data in tree structure with the check boxes at each nodes on a jsp page with out using any third party tools. how can i do that? Do i require any new tags to fulfill this requirement?
can any one help me out by sending any example code?
thanks in advance.
Regards,
ReddyOnce you have the data in a list or something, can't you just use <c:forEach> and then output standard nested <ul> and <li> tags to give the tree structure.
<html>
<style>
li
list-style-type:none;
</style>
<body>
<form>
<ul>
<li>
<input type="checkbox">Check 1</input>
<ul>
<li>
<input type="checkbox">Check 1A</input>
</li>
<li>
<input type="checkbox">Check 1B</input>
</li>
</ul>
</li>
<li>
<input type="checkbox">Check 2</input>
<ul>
<li>
<input type="checkbox">Check 2A</input>
</li>
</ul>
</li>
<li>
<input type="checkbox">Check 3</input>
</li>
</ul>
</form>
</body>
</html> -
How to get current time in TimesTen
I need to get the current timestamp of TimesTen DB located node, how can get it?
In PSQL, I can use built-in function now(), In Oracle, I can use LOCALTIMESTAMP, thanks. a lot.Hi Vikas,
Firstly, the syntax you give
select to_char(sysdate,'dd-mm-yyyy hh24:mi:ss.FF') as ts from dual;
does not work in Oracle DB - it gives an eror due to the '.FF' in the format string.
This syntax does work just fine in TimesTen (which is a little more tolerant).
However, this is not a very useful thing since the resolution of SYSDATE is 1 second and to accurately measure data fetch times you need accurate microsecond resolution. Also, you would need to take an average over many millions of measurements to get any degree of accuracy.
Realistically, this will be a very difficult thing to measure with any accuracy. Might I understand what you are exactly looking to achieve here? For the same amount of data, separateing 'fetch' from SQL execution, TimesTen in direct mode will return data much, much faster than an Oracle client/server connection wven when the client is on the same machine as oracle. For Tt client/server mode the data transfer performance will be very similar to that for Oracle.
Chris -
Hi,
I would like to know how to get the current time (07H25 for instance).
Does someone know how to do it ?
Thanks in advance, Fred.java.util.Date = new java.util.Date();
The above code produces an object which contains a timestamp (date and time) for the instance in which it was created.
To display it in any format you wish you would use the java.text.SimpleDateFormat class. -
How to get current time in seconds
Can someone please tell me how to get the current time in seconds. I am currently doing as follows but not sure if its correct or best way:
Calendar cal = new GregorianCalendar();
long currentTimeInSeconds = cal.getTimeInMillis()/1000;vik1491 wrote:
How about this:
Date date = new Date();
Format formatter = new SimpleDateFormat("HH:mm:ss");
String s = formatter.format(date);
String patternStr = "\\:";
String[] fields = s.split(patternStr);
int secondsSinceMidnight= Integer.parseInt(fields[0]) * 3600 + Integer.parseInt(fields[1]) * 60 + Integer.parseInt(fields[2]);
What about the day what you switch between standard time and daylight savings time? -
Anyone know how to get current time using Java?
Hi,
do anyone know how to use system.currentTimeMillis() to get the current time?
I know that system.currentTimeMillis() get the time between current time and midnight, January 1, 1970 UTC. but how to use it to get the current time format?
Thank you very much.Hi,
do anyone know how to use system.currentTimeMillis()
to get the current time?
I know that system.currentTimeMillis() get the time
between current time and midnight, January 1, 1970
UTC. but how to use it to get the current time format?
Thank you very much.
long timeInMillis = System.currentTimeMillis();
Calendar c = Calendar.getInstance();
c.setTime(timeInMillis);
Date d = c.getTime();And format using SimpleDateFormat:
SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy HH:mm:ss");
String formattedDateString = sdf.format(d); -
How to get current time and set to yyyy/mm/dd hh:ss
Dear friend:
how can i get computer current date and time and set to yyyy/mm/dd hh:ss
like this "2011/03/02 16:40:23" ? i want to pass this date to my sql server for quering.
thank for helpingsee this:
http://livedocs.adobe.com/flex/3_cn/langref/mx/formatters/DateFormatter.html -
How to get current time in GMT ?
hey all i want to get the current timestamp in GMT any ideas how to do that ?
jverd wrote:
sabre150 wrote:
java.sql.Timestamp does not have an explicit timezone. To quote the Javadoc, it is just "a thing wrapper round java.util.Date" Yup.
It has an implied timezone of UTC (same as GMT) and cannot be changed. I say again - it cannot be changed.I disagree. Though the definition is "millis since 1/1/1970 00:00:00.000 UTC", there's nothing in the object to reflect that it's 1/1/70 00:00 or that it's UTC. If the definition were changed tomorrow to "millis since 12/31/1969 16:00:00.000 PST", the class would not change at all. I wouldn't say that the identical class has an "implied TZ" of PST vs. UTC just by that change.
So while it's defined relative to a time in UTC, there's no TZ--implied or otherwise--that's part of the object.There is no field in Timestamp or Date that hold a Timezone so neither has an explicit* Timezone. The timezone is implied by the long value it holds being the defined as being the number of milliseconds since 1/1/1970 UTC. Of course this is only by convention. One can insert any long value one wants in it and say that this is the offset since any arbitrary epoch in arbitrary units in an arbitrary timezone but then non of the helper classes such as SimpleDateFormat would function correctly since they interpret the long value as being milliseconds relative to 1/1/1970 UTC.
Of course if you were really really bored and really felt like doing something pointless you could re-define the units for the long value and define your own epoch and write your own Date helper classes.
>
Yeah, I'm having a hard time focusing on work now, and felt a little pointless ballsniffing pedantry would be refreshing. :-):-) I suggest a couple of strong cups of Typhoo (If someone hasn't already done so, maybe I should create a JTyphoo API). Much better for you than Java. -
How to get Parameters in a jsp page called by VB program via xmlHttp
I have a VB programm sending a request using xmlHttp.
xmlHttp.Open "POST", varTarget, True 'True means asynchronous
xmlHttp.Send xmlSendStr
This worked fine with ASP
the crucial ASP code was:
set xml = server.createObject("MSXML2.DOMDocument")
xml.load(request)
VBData = cstr(xml.getElementsByTagName("value").item(0).firstChild.nodeValue)
now I have a webserver (tomcat) and try to have a simular functionality
but
request.getParameter()
seems not to do the job.
what do I have to do
I am thankfully looking forward to you reply
peterHi,
thanks for your reply!
If I have the parameters in the URL and use the method GET it works all right.
but I need the method to be POST. I suppose, I have the wrong way identifying the parameter name
This is from VB
varTarget = "http://localhost:9090/gm/getData" ' getData is my servlet
xmlSendStr = "SQLStmt=SELECT TCPD_Cars.* From TCPD_Cars WHERE (((TCPD_Cars.CarIdent)=45));"
xmlHttp.Open "POST", varTarget, True 'True means asynchronous
xmlHttp.Send xmlSendStrthis is part of my Servlet
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
String SQLStmt = request.getParameter("SQLStmt") ;
//make the database query and get the returns
writer.println(GetSQLData(SQLStmt));
//close the write
writer.close();
}I would appreciate any suggestions -
How to get server time in Oracle Internet Directory (OID)?
Hi,
How to get current time on OID server? As in case AD, RootDSE contains currentTime attribute, Is there any attribute in OID through which I can get current time on server.
Thanks in advance for any help.
Regards,
UmeshHi,
wrong forum, use Identity Manager
Frank -
How can i get current time of a given timezone
how can i get current time of a given timezone
for example: Asia/Hong_Kong
my code is like this, but the result is not correct.
what's wrong?
import java.util.*;
public class test {
public static void main(String[] args){
String s = "Asia/Hong_Kong";
String tempS = "";
TimeZone myTime = new SimpleTimeZone(s);
//TimeZone myTime = TimeZone.getTimeZone(s);
Calendar myCal = new GregorianCalendar(myTime);
tempS = myCal.get(Calendar.YEAR)+"-"+
(myCal.get(Calendar.MONTH)+"-"+
myCal.get(Calendar.DATE)+" "+
(myCal.get(Calendar.HOUR)+":"+
myCal.get(Calendar.MINUTE)+":"+
myCal.get(Calendar.SECOND);
System.out.println(tempS);
output is : 2001-7-15 11:16:48
but the correct time should be: 2001-8-16 7:17:48
the correct time should be 2001-8-16Certain indexes in the Calendar API start at 0 rather then 1, so, when you get the value, you may want to increment.
I'm not sure why the time is incorrect. You may want to call getAvailableIDs() and make sure that the desired TimeZone ID is supported by your version. I doubt that Sun would have incorrect support for the time zone, but it may not be included, or perhaps it is included with a diffrent ID. You can always create your own time zone as well, by passing the String offset to getTimeZone(), the offset being how many hours beyond or before GMT. Hopefully this helps.
Maybe you are looking for
-
Home Hub 3 is slower than dial up.
I used to be on a voyager 220v router but started having connection problems. After speaking to customer support, and after they ran some tests on the line/router, they told me that the fault was with the 220v and as it was obsolete, i would need to
-
Activate "Open Item Management" for an Asset, line items posted previously
Dear Experts, In Asset there are line items already posted but it is not "Open Item Management" only "Line Item Display" is activated. Now we want this as "Open Item Management". We are using ECC 6.0. Please help... how to go about it? - Nilesh
-
How to bring Pop up while opening any transaction
Hi All, I need to give Pop up when any one open some transaction. Please advice. Thanks, Gaurav Mittal
-
Hi, Field exit was created with CMOD, but is not processed when calling the screen. Thanks, Biju
-
Aperture 2.1.4 shows landscape JPEGs as "Unsupported Image Format"
I have just imported a few JPEGs from a Boots scan of some 35mm film I had processed there. All 7 portrait aspect photos are fine, but all 8 landscape format images come up as "Unsupported Image Format" on the maroon screen of death. The original s