Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Jolly Khanna

+ Follow
since Sep 24, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jolly Khanna

Can someone please help?
Here's the problem I'm having:

I have a user who enters a product number on the JSP page (let's call it page1.jsp). The user hits the submit button and the product number goes to a Java Action class that retrieves the product from a database. The results are stored in a Table. The table is stored in a session in the Java action class like so:
session.setAttribute("tablegrid", table);
The table consists of rows and columns. Rows represent the product's COLORS, and columns represent the SIZES available. The user is then forwarded to page2.jsp, which displays the results in table format. In page2.jsp, the user can enter values in each cell. The values represent quantity. At the bottom of page2.jsp, there's a text box where the user can enter another product number. When the user enters another product number and hits the "next" button, the values for the current product are stored/saved, the Java action class is called again, and the next table is built based on the number you entered and stored in the session. page2.jsp is refreshed with the new table. If the user decides to hit the browser's 'BACK' button while they are in the middle of entering values for this new table, the page should show the previous values the user entered. The user can enter many product numbers and fill in the table values. This can go on until the user hits the "finished" button on page2.jsp, at which time they are directed to summary.jsp. summary.jsp will show a summary of all the tables and values they entered for each cell.

How can I store the values for each product the user enters? What is the best approach? And how can a recall these values if the user hits the back button? I thought about storing the values the user enters in a Hashtable but how do I associate the hashtable with the product number?



<form name="test" action="">
<input type="text" name="products">
<input type="button" value="submit">


<% ResultData tab = (ResultData)session.getAttribute("tablegrid"); %>

<form name="products" action="">
for(int i = 0; i < 10; i++)
{ %>
for(int i = 0; i < tab.getNumRows(); i++) { %>
<td><input type="text" name="<%= tab.getString(i) %>" value=""></td>
<% } %>
} %>

<input type="text" name="nextItem">
<input type="button" value="NEXT">
<input type="button" value="FINISHED">

//Some logic

Hashtable products = new Hashtable();
//This is how I am currently saving the values the user entered
while (enum.hasMoreElements())
String name = (String) enum.nextElement();
if(request.getParameter(name) != null && request.getParameter(name).length() > 0)
products.put(name, request.getParameter(name));

//some more logic
17 years ago
Thanks for informing me about Stuts token's. I tried to use them but it's a little confusing. I've tried it many different ways but none seem to work. Below is the code snippet that is causing me problems:
...(update the datebase)
The problem is isTokenValid ALWAYS returns false. It doesn't matter where I put saveToke(). Does any one have any ideas?
18 years ago
What is the best approach or solution for the following problem:
I have a jsp page that calls an action class which, in turn, deducts a value from the database. Upon completion of this deduciton, the page gets sent to "success.jsp", but when I right-click the jsp page and click on "refresh" the action gets called again and another deduction takes place. For example, I have a DB column called "Amount" and the initial value is 10. When the user logs in I want to deduct 1 from amount. "success.jsp" show the amount with the value of "9". When I click on refresh, it says "8", then "7", "6", etc. Is there a way to prevent the action from executing and, subsequently, updating the database everytime a user tries to refresh?
Any help would be greatly appreciated.
18 years ago
Hi Everyone,
This has me STUMPED!
I want to check to see if the date a person enters is before or after 6 PM tomorrow. The date the user enters comes in the format MM/dd/yyyy. If it's currently before 6:00 PM then they are allowed to enter tomorrow's date or later (but not today�s date). If it's currently AFTER 6 PM, then they can only enter the day after tomorrow or later. This seems easier than it is but, for the life of me, I just can't figure it out. If anyone can help I'd really really apprecaite it. Here's what I have so far. Can anyone stear me in the right direction?
Calendar requestedDate = new GregorianCalendar();
Calendar tommorrow = new GregorianCalendar();
tommorrow.add(tommorrow.DATE, 1);
SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
String date = "3/20/2002";
Date parseDate = df.parse(date);
if(requestedDate.equals(tommorrow) || requestedDate.after(tommorrow) && now.get(Calendar.HOUR_OF_DAY) < 14)
System.out.println("no problem entering");
System.out.println("problems entering");
20 years ago
That's great! Thanks John.
But what if I want to check if the requested date is 2 days later than today's date? Is there a method that I can simply add a number of days to the date which will automaically rollover to the next month? EX. If date=2/28/2002 and I want to add 2 days, will it automaically jump to March 2?
20 years ago
I was wondering how can I compare today's date to see if it is before or after a date entered by the user in the format: MM/DD/yyyy?
Do I have to parse the data first and then compare?
20 years ago
Hey Bear,
Thanks for your help.
The request.getParameter() was being used to set the value of "name" to an object. In my Servlet I was calling String name = request.getParameter("name"); but the value was coming up null.
20 years ago
In my jsp page, I'm setting the value of a hidden textbox and I'm trying to retrieve the contents of that text box in a Servlet using request.getParamter, but I'm getting "null" as a result. First I set the value of the hidden paramter in javascript. I don't use an "action" for my form. Instead I use location.href in javascript. Can someone PLEASE help?
Here is the JSP page:
function setValue(str1, str2)
{ = str2
location.href = "/myPage/" + str1;
</javascript >
<form name="test"><input type=hidden name="name" value="">
</form >
<a on_click = "setValue('Hello', 'World');" Click me!</a >
20 years ago
Great suggestions! But how would I maintain the relationship on the second page?
20 years ago
I thought this was an easy one but I can't seem to find the anwser:
How can I retrieve the value of a label in a JSP page?
Thanks for your help!
20 years ago
I think I figured it out.
#1) Change setenv.bat
change the above to
set JAAS_OPTIONS1=%J2EE_HOME%\lib\security\jaas.policy
set SSL_OPTIONS1=%J2EE_HOME%\lib\security\cacerts.jks
set LISTEN_OPTIONS=-Dcom.sun.CORBA.connection.ORBListenSocket
set JAVACMD=%JAVA_HOME%\bin\java -Xmx128m
#2 Change j2ee.bat
%JAVACMD% %LISTEN_OPTIONS% -Dorg.xml.sax.parser=org.xml.sax.helpers.XMLReaderAdapter -Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl -Djms.home=%JMS_HOME% -Dcom.sun.jms.service.jdbc.dbpath=%JMS_DB_PATH%\config\\lib\security\server.policy\lib\security\login.config -Dcom.sun.enterprise.home=%J2EE_HOME% -classpath %CPATH% com.sun.enterprise.server.J2EEServer %*
Change the above to
%JAVACMD% %SSL_OPTIONS%=%SSL_OPTIONS1% %JAAS_OPTIONS%=%JAAS_OPTIONS1% %LISTEN_OPTIONS%=%LISTEN_OPTIONS1% -Dorg.xml.sax.parser=org.xml.sax.helpers.XMLReaderAdapter -Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl -Djms.home=%JMS_HOME% -Dcom.sun.jms.service.jdbc.dbpath=%JMS_DB_PATH%\config\\lib\security\server.policy\lib\security\login.config -Dcom.sun.enterprise.home=%J2EE_HOME% com.sun.enterprise.server.J2EEServer %1 %2
Notice that we changed "com.sun.enterprise.server.J2EEServer %*" to
"com.sun.enterprise.server.J2EEServer %1 %2"
-After making these changes I was able to start my j2ee server on Windows 98.
Good luck!
Hi Johnson,
I've what you said and it still doesn't work. I'm running Windows 98. Here's my environment settings:
SET JAVA_HOME=C:\jdk1.3.1_01
SET J2EE_HOME=C:\j2sdkee1.3
SET J2EE_CLASSPATH=C:\j2sdkee1.3\lib\j2ee.jar
SET ANT_HOME=C:\jakarta-ant-1.4-bin\jakarta-ant-1.4
I get the following message when I type "j2ee -verbose" at the command prompt:
Syntax error
Syntax error
Syntax error
Java 2 Enterprise Edition Server
-help ...