Beginning Programmer needs help - JSP and databases?
1. I have never used JSP before, but have been given an assignment to create a webpage to query a database. The database is in Access. Does anyone have a snipet of code in JSP that will query an MS Access database. Is there a function that I can use and pass it an SQL (select statement) and have it return a list of results.
-OR-
If there is a way for JSP to transform the MS Access database into a text file that would be good also.
2. Has anyone created a search functionaly using JSP (or know of a tool) that can search documents, PDF files, HTML files, etc.
Thank you for any help!
hi , there is no big deal in JSPs, Servlets, EJBs e.t.c its olnly a matter of committing time and getting urself familar and in areas where you have problems this forum is a nice place for you to share all what u have.
to start with i will give you some sites where you can start learning jsps, servlets, ejbs and the rest.
1) http://java.sun.com/j2ee -> look for JSPs , Servlets, EJB, JavaBeans e.t.c
2) http://www.jspinsider.com
3) http://www.coreservlets.com
4) http://www.jakarta.apache.com (download tomcat for your container)
for databases u can use this code snippet but u will have to read more about databases to be able to chagne some things in this snipper such as your database username, password , url and the rest.
<%@page import="java.sql.*" %>
try
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection ("jdbc:odbc:test_dsn", "sa", "");
Statement stat = con.createStatement ();
ResultSet res = stat.executeQuery("select * from authors");
while (res.next())
//process the results of this query
catch (Exception e)
//process this also
%>
You will need to become farmilar with the java programming language and also database conventions so you have a proper understanding.
study those db codes and modify to suit your needs.
buzz on me in case you are stuck.
Regards
Similar Messages
-
Help,JSP and SERVLETS!
hello:
i've downloaded ECLIPSE 3.2,TOMCAT 5.5 .
i tried to build simples examples o servlets but i failed could you please tell me how to proceed?i'm new at this plus i've got a project to do with all this so plz can you give some links to go,i tried but no links was clear.
i've got to give to my professor an examples executed (servlets,jsp)
thank youHISSO wrote:
i wil give up on talking about stupid gossip
you must act professional and i you can't help it's ok
so plz i juste want help
i'm so busy finishing my studies
when it comes to talk about development with tomcat and eclipse together i'm new so i need some advices,so plz let's be serious!
i'm working hard to finish my project!Try to communicate less like a monkey with electrodes attached to it's genitals. This means stop using words like "plz" and write "please" instead.
If you want specific help with a specific problem then you should ask a specific question. "help, JSP and SERVLETS" is not a specific question. And you should also note that if your specific question is about Tomcat specifically or Eclipse specifically then you are in the wrong place to begin with.
So do you want to try again? -
I need help deleting and adding text
i need help deleting and adding text, can soneone help
Adobe Photoshop Elements 10You should delete your phone number from the topic line.
Spambots search these forums for contact info.
You don't want to get even more telemarketing/scam calls than you probably already get.
It seems like the "Do Not Call" lists are ignored these days.
Message was edited by: Bo LeBeau Looks like someone already took care of this. -
I need help scrolling and highlighting for a vast amount of pics that I'm trying to transfer. I have a macbook pro osx 10.5.8
I need help scrolling and highlighting for a vast amount of pics that I'm trying to transfer. I have a macbook pro osx 10.5.8
-
Please help with jsp and database!!
Hello,
i first created a jsp page and printed out the parameters of a user's username when they logged in. example, "Welcome user" and it worked fine...
i inserted a database into my site that validates the username and password, and ever since i did that in dreamweaver, when a user logs in sucessfully, it returns the jsp page like its supposed to, only that it says "Welcome null" instead of "Welcome John." pretty strange, huh!? can anyone please help? thanks!
here is the important part of the code to Login.jsp, and LoginSuccess.jsp: <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<%@ include file="Connections/Login.jsp" %>
<%
// *** Validate request to log in to this site.
String MM_LoginAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) MM_LoginAction += "?" + request.getQueryString();
String MM_valUsername=request.getParameter("Username");
if (MM_valUsername != null) {
String MM_fldUserAuthorization="";
String MM_redirectLoginSuccess="LoginSuccess.jsp";
String MM_redirectLoginFailed="LoginFailure.jsp";
String MM_redirectLogin=MM_redirectLoginFailed;
Driver MM_driverUser = (Driver)Class.forName(MM_Login_DRIVER).newInstance();
Connection MM_connUser = DriverManager.getConnection(MM_Login_STRING,MM_Login_USERNAME,MM_Login_PASSWORD);
String MM_pSQL = "SELECT UserName, Password";
if (!MM_fldUserAuthorization.equals("")) MM_pSQL += "," + MM_fldUserAuthorization;
MM_pSQL += " FROM MemberInformation WHERE UserName=\'" + MM_valUsername.replace('\'', ' ') + "\' AND Password=\'" + request.getParameter("Password").toString().replace('\'', ' ') + "\'";
PreparedStatement MM_statementUser = MM_connUser.prepareStatement(MM_pSQL);
ResultSet MM_rsUser = MM_statementUser.executeQuery();
boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
if (MM_rsUser_isNotEmpty) {
// username and password match - this is a valid user
session.putValue("MM_Username", MM_valUsername);
if (!MM_fldUserAuthorization.equals("")) {
session.putValue("MM_UserAuthorization", MM_rsUser.getString(MM_fldUserAuthorization).trim());
} else {
session.putValue("MM_UserAuthorization", "");
if ((request.getParameter("accessdenied") != null) && false) {
MM_redirectLoginSuccess = request.getParameter("accessdenied");
MM_redirectLogin=MM_redirectLoginSuccess;
MM_rsUser.close();
MM_connUser.close();
response.sendRedirect(response.encodeRedirectURL(MM_redirectLogin));
return;
%>
<form action="<%=MM_LoginAction%>" method="get" name="Login" id="Login">
<table width="55%" border="0">
<tr>
<td width="41%">Username </td>
<td width="59%"><input name="Username" type="text" id="Username" value="" size="25" maxlength="10"></td>
</tr>
<tr>
<td>Password </td>
<td><input name="Password" type="password" id="Password" value="" size="25" maxlength="10"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>And LoginSuccess.jsp where i want it to print out the "Welcome username
<%String Name=request.getParameter("Username");
out.println ("Welcome ");
out.println (Name); %><%@ page contentType="text/html; charset=iso-8859-1"
language="java" import="java.sql.*" %>
<%@ include file="Connections/Login.jsp" %>
<%
// *** Validate request to log in to this site.
String MM_LoginAction = request.getRequestURI();
if (request.getQueryString() != null &&
request.getQueryString().length() > 0) MM_LoginAction
+= "?" + request.getQueryString();
String
MM_valUsername=request.getParameter("Username");
if (MM_valUsername != null) {
String MM_fldUserAuthorization="";
String MM_redirectLoginSuccess="LoginSuccess.jsp";
String MM_redirectLoginFailed="LoginFailure.jsp";
String MM_redirectLogin=MM_redirectLoginFailed;
Driver MM_driverUser =
=
(Driver)Class.forName(MM_Login_DRIVER).newInstance();
Connection MM_connUser =
=
DriverManager.getConnection(MM_Login_STRING,MM_Login_US
RNAME,MM_Login_PASSWORD);
String MM_pSQL = "SELECT UserName, Password";
if (!MM_fldUserAuthorization.equals("")) MM_pSQL +=
= "," + MM_fldUserAuthorization;
MM_pSQL += " FROM MemberInformation WHERE
E UserName=\'" + MM_valUsername.replace('\'', ' ') +
"\' AND Password=\'" +
request.getParameter("Password").toString().replace('\'
, ' ') + "\'";
PreparedStatement MM_statementUser =
= MM_connUser.prepareStatement(MM_pSQL);
ResultSet MM_rsUser =
= MM_statementUser.executeQuery();
boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
if (MM_rsUser_isNotEmpty) {
// username and password match - this is a valid
lid user
session.putValue("MM_Username", MM_valUsername);
if (!MM_fldUserAuthorization.equals("")) {
session.putValue("MM_UserAuthorization",
ion",
MM_rsUser.getString(MM_fldUserAuthorization).trim());
} else {
session.putValue("MM_UserAuthorization", "");
if ((request.getParameter("accessdenied") != null)
ll) && false) {
MM_redirectLoginSuccess =
ess = request.getParameter("accessdenied");
MM_redirectLogin=MM_redirectLoginSuccess;
MM_rsUser.close();
MM_connUser.close();
response.sendRedirect(response.encodeRedirectURL(MM_re
irectLogin));
return;
%>
<form action="<%=MM_LoginAction%>" method="get"
"get" name="Login" id="Login">
<table width="55%" border="0">
<tr>
<td width="41%">Username </td>
<td width="59%"><input name="Username"
="Username" type="text" id="Username" value=""
size="25" maxlength="10"></td>
</tr>
<tr>
<td>Password </td>
<td><input name="Password" type="password"
="password" id="Password" value="" size="25"
maxlength="10"></td>
</tr>
<tr>
<td>�</td>
<td><input type="submit" name="Submit"
me="Submit" value="Submit"></td>
</tr>
</table>
</form>
And LoginSuccess.jsp where i want it to print out the
"Welcome username
<%String Name=request.getParameter("Username");
out.println ("Welcome ");
out.println (Name); %>When the page is rediredted u r not passing the user name in the query string,so it is not availble in the query string for LoginSuccess page
Since u have added user in session user this
<%String Name=(String)session.getValue("MM_Username") ;%>
<% out.println ("Welcome ");
<% out.println (Name); %> -
Need help in creating Database connection to Apache 4
I desperately need help for my project. I'm doing a shopping cart project. Created a java bean to establish connection to my sql 7 server database. But the following always appear. I'm using dreamweaver mx to create my webpage and so I use its binding and components feature.
Here's the error message I always get..
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occurred at line: 36 in the jsp file: /TMP8ouafocg7v.jsp
Generated servlet error:
C:\tomcat4\work\Standalone\localhost\ArtGallery\TMP8ouafocg7v$jsp.java:163: Class org.apache.jsp.DBConn not found.
DBConn connect = null;
^
An error occurred at line: 36 in the jsp file: /TMP8ouafocg7v.jsp
Generated servlet error:
C:\tomcat4\work\Standalone\localhost\ArtGallery\TMP8ouafocg7v$jsp.java:166: Class org.apache.jsp.DBConn not found.
connect= (DBConn)
^
An error occurred at line: 36 in the jsp file: /TMP8ouafocg7v.jsp
Generated servlet error:
C:\tomcat4\work\Standalone\localhost\ArtGallery\TMP8ouafocg7v$jsp.java:171: Class org.apache.jsp.DBConn not found.
connect = (DBConn) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "DBConn");
^
3 errors, 1 warning
Anyone out there, pls let me know the solution soon. Thanks!I was glad I came across this note. I recently started a tutorial on J2EE , and have run into exactly the same error. Have you found a solution? Can you share it with me?
Thanks..... -
I need contact sheet and database.
I have a musician's referral service on a website and I need a way for the info they fill out on the contact sheet to be imported into a database. I need a fast and easy way to do this. It all seems so complicated to me, one not familiar with this technology. Any suggestions.
If you just want to save the contact info (from the website, which is the front-end, probably written in html) into a database, then using the above said Oracle XE and ApEX would be superfluous in my opinion. It involves multiple tiers and servers like database, web/http server etc, and as you said it is little complicated too.
But don't mistake me that I am discouraging you from using Oracle XE and ApEX, it’s like using a cannon for a mouse hunt :). At the same time, if you plan to develop your application/website into some kind of portal or bigger application, that involves more activity and transaction, then Oracle XE and ApEX would be the option to start with. Then you got to learn the technology or hire someone who knows the technology.
Also note that you can easily achieve your above said requirement with html and MS Access database or even with MS Excel spreadsheet, which is less complicated and easy to manage.
There are websites like www.elance.com where you can describe your requirement, there are individuals and companies who will study your requirement, provide you the system requirements, quote and methodology in implementing it.
Hope it helps,
Babu Rangasamy -
I need help, motherboard and RAM
Tomorrow morning I have to buy all the parts, and only left me two.
My options were: Deluxe Asus P9X79-WS, Asus X79 Rampage or ASRock Fatal1ty Champion,Gigabyte Ga-X79s- UP5
Any other options?
Hare 3930k OC without touching the voltage.
In thinking about the G.Skil RAM but it is 1.6 v ...
Please i need help.
My system:
Gigabyte GeForce GTX 670 OC 2GB GDDR5 http://www.pccomponentes.com/gigabyt...2gb_gddr5.html
Intel I7-3930K http://www.pccomponentes.com/intel_c...cket_2011.html
Corsair HX650 650W 80 Plus Gold http://www.pccomponentes.com/corsair...plus_gold.html
Noctua NH-D14 http://www.amazon.es/gp/product/B002...A1AT7YVPFBWXBL
Corsair 500R Carbide Series Blanca http://www.pccomponentes.com/corsair...es_blanca.html
Samsung 840 Pro SSD Series 256GB SATA3 Basic Kit http://www.pccomponentes.com/samsung...basic_kit.html
2x Seagate Barracuda 7200.14 1TB SATA3 http://www.pccomponentes.com/seagate...1tb_sata3.html
ThanksYou might go to the CS5 Benchmark http://ppbm5.com/ and see if there is a motherboard sort... I think ASUS is used more than either of the other two brands you mention
A note from Harm about ram http://forums.adobe.com/thread/1089842 -
I have an ipod touch 4th gen and when I plug it into my computer it shows up but it wont on iTunes and I was trying to put more music on it today and it wasn't showing up can u help please and thank you.
Hey Babetta94,
Thanks for using Apple Support Communities.
After reviewing your post, the iPod is not recognized in iTunes. A frustrating situation to be sure. You haven't mentioned what OS the computer you are using uses. You can choose what article to use either OS X or Windows from this quoted section.
iPod not appearing in iTunes
http://support.apple.com/kb/TS3716
If you have an iPod touch:
For Windows: See iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows
For Mac OS X: See iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X
Have a nice day,
Mario -
Non-Programmer Needs Help!!! (desperately)
Ok, I want to create games for a virtual world website. I also want the website to be a game itself. Right now, I am working on creating a card game for two players (with the option of playing the computer). They each have 2 decks to draw from and a place for 2 cards to be displayed (their "hand") before they place it on the game board. I don't want their opponent to see the cards in their "hand" until they are placed on the game board. When a player has two cards in his hand, I want them to have the capability of enlarging the image of the card to full size in a pop-up type window, so they can calculate their strategy. The game itself is similar to the popular battle card games, so regular playing card games don't help me. I want the image of the card to be displayed on the game board either right side up or upside down depending upon the button pushed by the player. I want each player to play 1 card from one pile (blue-50 cards total) and 4 cards from the other pile (red-200 cards total). They can only draw 1 blue card, and 1 red card on their first turn. After that, they can only draw 1 red card per turn, until they have drawn 4 red cards total. The total number of cards each player can have on the game board is 5 cards, then the round ends. Each deck has the same cards but shuffled in random order. The decks can't be stacked the same, for each player. Each card has a certain value. The card from the blue pile is the main card that the cards from the red pile will add to or subtract from. If the match between the opponents is tied, no score is given to either player, but the cards from both players to go to the corresponding "tie" piles (one red and one blue) that will be randomly distributed by the computer, once each player has exhausted their own decks first. The tie piles are used at the end of the game to play the final round or rounds of the game. After each round, the victor of that round gets the points on his opponents cards, plus 1000 points for winning the round. I want the cards to just "disappear" or placed in the computer's "discard" pile after each round, so they cannot be used again. I want each player to have a turn being first at the beginning or each round. (If player 1 is first in round 1, player 2 will go first in round 2 and so on.) I want the scores for each card to be calculated and placed in a box according to which player the cards belong to. Once the round is ended, the victor will receive the final score in their "total score" box. I also want a "round number" box to indicate which round it is. No winner will be declared until the players use all their cards and/or the computer deals all the tie deck cards (which are shuffled before dealing). At the end of the game, the person with the highest score is the winner.
I also would like to allow players to challenge each other and accept or decline a challenge. In order to do that, the players must login first. There must also be a list of available players to challenge.
Is there a program that not only builds the user interface, but also will allow me to insert my graphics? Kind of like WYSIWYG HTML builders? (Preferably FREE) I have a gui builder, but have no clue as to how to put in the graphics or get it to work. I don't have any connections to the programming world, nor am I able to return to school at this time. The programs that Sun offers are not adequate for me, because I need to be able to install it, and run it without going through the "msdos classpath" thingy. I need a "wizard" type program that is truly for "dummies." Something that I can just put in my images and tell it what I want it to do IN PLAIN ENGLISH. For instance, if I want the "login button" to save the login information to a file and/or to the game. The players can have their same login info stored in a file, and they can return without creating a new name. The website service I want to place this on, doesn't allow chmoding for CGI, so I can't use that. Another example, if I want each card to have a differnt point level and either subtract from or add to the blue. Or how to get the pop-up for the card displayed in the player's hand. I don't know what else to do. Any suggestions?<blockquote>
The programs that Sun offers are not adequate for me, because I need to be able to install it, and run it without going through the "msdos classpath" thingy. I need a "wizard" type program that is truly for "dummies." Something that I can just put in my images and tell it what I want it to do IN PLAIN ENGLISH. For instance, if I want the "login button" to save the login information to a file and/or to the game. The players can have their same login info stored in a file, and they can return without creating a new name. The website service I want to place this on, doesn't allow chmoding for CGI, so I can't use that.
</blockquote>
This is a surely a joke. You honestly expect to get this for free. Even for an experienced programmer, to write 3/4 decent games - configure them to your network and meet these conditions. You're talking BIG or big-ish project here. As per your request, there is no such thing as point and click programming and there never ever will be.
Use Macromedia Director. Closest thing you'll get to
WYSIWYG programming. It's for simpletons and
non-programmers.Ah, noooo. The shockwave games have been programmed in Lingo, which is quite powerful and much harder as a programming language than java (its also outdated, has some nasty featured and its a definite falling star). Flash gets a bit nearer with a point and click effort and you can do a surprising amount without knowing about programming, also as a media for the Internet its better supported than Shockwave and even java for the Web. But for any sort of worthwhile game need sprogramming knowledge.
To conclude:
you don't want to learn to program.
noone is going to do this for you.
You're a bit f***ed then aren't you.
On a brighter note, if you pay me ?1,000.00 (half in advance), I'll think about it - solution in java or Flash, 3 games, ?1,500.00 for both. I can take it or leave it btw, couldn't give a sh*t either way. -
Need help connecting to database on website!!!!
Hi there
I am doing a school project and have decided to make a database which i can store user info and car info (its a car auction program)
But i am having trouble with the connection to the database... we have been told to use jdbc odbc connection so is there a way to use this method to connect to my database?
this is my connection code when connecting to the database locally:
con = DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=CarDealership.accdb");
i omitted the other code because it is pretty standard code to do this connection.
But now i want to connect to a database of the same name on this site:
sites.google.com/site/card3al3rsh1p
what must i change in my code to be able to connect to the database on the internet????
please please plssssssss help me really want to get this to work
thanks and regardsOK I apologise and realise I was in a rush. I will try explain more clearly now.
I am using Netbeans 7 and am having troubles connecting my java program to a Microsoft Access database which is on this website:
sites.google.com/site/card3al3rsh1p/
The database name is "CarDealership.accdb".
When I use the class below to connect to my database locally, it is a success.
import java.sql.*;
public class DB {
Connection con;
Statement stm;
ResultSet rs;
public DB(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=*CarDealership.accdb*");
} catch(Exception ex){
System.out.println("Error opening database.");
System.out.println(ex);
System.out.println("Database successfully opened.");
However, when I change the bold text above (or the text between the asterisks, not sure if it will change) to "sites.google.com//site//card3al3rsh1p//CarDealership.accdb" it throws an error signifying that it can't find the file specified.
I am unsure of how to connect my program to an external file so I need assistance in how to change the url String of the DriverManager.getConnection() method above so it can connect to the database on the website mentioned above. I would appreciate it if you could assist and thanks. -
Need help connect Access Database to Crystal Report Viewer in java
Need example for passing parameters to PropertyBag Class and IConnectionInfo Class.
We use CR_JRC_11.8
ThanksA sample that demonstrates how to change the database that a report uses at runtime in the JRC can be found at the following link on the SAP Portal:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0ad3d3d-be66-2b10-2181-f46c6e05a420
To help determine what connection properties need to be changed at runtime through code, create a copy of your original report and use the Crystal Reports designer to change this report to new datasource manually. You can then use the jrc_display_connection_info helper sample to examine what the parameters should be in the property bag before setting the IConnection information. The jrc_display_connection_info helper sample can be found at the following link on the SAP Portal:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/706202a4-bd66-2b10-4e8b-92f4a8024ea1
Hope these samples help.
Regards.
- Robert -
Hi All,
To start of I'm just a beginner to JSP.
I've made some JSP pages that get some database info, all works fine but
I do have the database code in the JSP page. And I know that this is not the
ideal method.
I've read that the database code should be seperate from the JSP code, but
how would I do this? Are there any tutorials on the net on how?
Thanks for any help!Use MVC architecture. There are lot of tutorials available. One of them are in
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html -
Hi,
I have created a JFrame with a JSplitPane and placed a JTree in the left side of the SplitPane. I made a class that populates the tree with a tree of options. When the user clicks the tree I want he right pane to change. The treemenu was an event listner that is working fine.
The problem is the left pane is in a separate .java file called TreeMenu. On the JFrame I simply create a new instance of it and it populates the tree for me.
As a VB programmer I would declare my TreeMenu to have an event such as MenuChanged("Selected Help"). The JFrame would see the message and call the right pane to update.
How do I do this in Java? My problem occurs when I move code out to a separate class. If everything was done frm the one frame then I would be fine, but i want to modularise the application.
Please help.
AaranHere's a bit of code that may help you with your modularity issues.
File: Switchboard.java
interface Switchboard {
void operator(TreeData identity);
}File: CallMaker.java
import java.awt.event.*;
public class CallMaker implements TreeSelectionListener {
private TreeData identity;
private Switchboard destination;
CallMaker( TreeData id, Switchboard swbd ) {
identity = id;
destination = swbd;
public void valueChanged( TreeSelectionEvent e ) {
destination.operator( identity );
}For what you're trying to do I would suggest the following:
1)Declare the Tree Populator to implement the Switchboard interface.
2)put the code that populates the table into the operator method, or
simply call the class/method that populates the tree from the
operator method.
3)Use an instance of the CallMaker class as a Listener on your tree.
It should work something like this:
public class PanePopulator implements Switchboard;
//Other code and whatnot...
public void operator(TreeData td) {
//Decide how to populate the right pane
//based on the TreeData. Call other classes/methods.
}In a separate file...
public class TreeSide {
JTree tree = new JTree();
//initialize the tree.
TreeData treeInfo = new TreeData();
PanePopulator rightPane = new PanePopulator();
tree.addTreeSelectionListener(new CallMaker(treeInfo, rightPane));
treeInfo = (TreeData)theCurrentTreeSelection;
}as long as treeInfo contains the data you need to populate the right pane, you'll be fine.
When a selection is made the CallMaker instance calls: rightPane.operator(treeInfo);
This provides your rightPane instance with the information it needs to populate the rightPane. -
Beginner Programmer needs help...
I just have a quick question regarding the get(MINUTE) function in the Calendar class. I am using this to display the current time on a webpage, and every thing seems to work fine except that if the current time has the minutes < 10 (ie, 2:04 or 8:09, etc.) then only that single integer is displayed (2:4, 8:9). I understand why this is happening, but I was wondering if there is a simple way to add a leadign '0' to this int. Here is that section of code...
int hour = cal.get(Calendar.HOUR);
int minute = cal.get(Calendar.MINUTE);
String ampm = (cal.get(Calendar.AM_PM) == 0 ? "AM" : "PM");
%>
<p class="body"> Hello <b><%= res.getString("fname") %> <%= res.getString("lname") %></b>.
It is <b><%= hour+":"+minute+" "+ampm+" on "+mo+"/"+dt+"/"+yr %></b>.</p>
This page is in JSP. Thanks a lot for the help!Replace minute with this. It should format it with a leading zero if needed
new DecimalFormat("00").format(minute)
Maybe you are looking for
-
my computer is very slow I have 98mbps to the modem but when i run a ping test on the machine i get 20 mbps and sometimes it is .10 mbps- do i need to upgrade my wireless modem on the machine? what can i do?
-
Problems running java applet in 1.4.2
Hi, I need some help with running an applet in the following environment: Win 98 ver 2 jre 1.4.2 IE 6.0 My applet runs in AOL within the same environment. However, the one we wrote does not run in this at all. I get the characteristic grey patch. Add
-
I have constant freezing when opeing up Final Cut Pro X (10.1) - the message given by the welcome-screen is "Restoring the window layout". I know this is an "old" problem and I've had it with earlier versions of FCPX as well - but now with 10.1 the p
-
Count number of ticket in per organigation.
hello expert. i have one internal table like that. org unit | ticket 1 aaa 1 bbb 1 ccc 2 | ddd 2 | eee 3 fff 4 ggg now my requirment is i have to calculate ticket number in per org unit. in given senario orgunit 1
-
Error when using service groups
Hello, When i try to configure service groups, wich i need in my bpm process, i always get an error message: An Unexpected ER Technical Exception occurred Service-Definition with name "2a4dec73:1242bb78370:3b04_webservice" don't exsists I tried it