Mark Leong

Ranch Hand
+ Follow
since Dec 11, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mark Leong

I have actually placed the application at webappcabaret.net. However it has not be listed at the application directory.
The error is obtained from the log file.
For development, I run RH7.1, Java 1.3.0_02, tomcat 3.2.1.
Will make a test using tomcat 4.0.4 + Java 1.4
22 years ago
The download servlet worked on the test server. Wouldn't that make it work on the actual host?
22 years ago
I am trying to download files through a servlet using the classes from Jason Hunter. The webserver showed the following:-
java.lang.IllegalStateException: getOutputStream has been called on this same request
at ezj.g.a.h.getWriter(Unknown Source)
at ezj.g.a.h.sendError(Unknown Source)
at smallcon.jobcontrol.downloadfile.doPost(downloadfile.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at ezj.engines.EZServletRunner.service(Unknown Source)
at ezj.b.a.a(Unknown Source)
at ezj.b.c.handleConnection(Unknown Source)
at ezj.b.e.run(Unknown Source)
Can anybody explain what the above mean and how to solve the problem?
22 years ago
Thanks for all the help. I found the problem.
I've placed a <pre></pre> tag within the cell. Removed it and all is OK.
22 years ago
Thanks.
That was actually what I first tried.
22 years ago
What I am trying to say is that the width attribute of the tables does not seem to work when the table is generated by servlet.
I have a very long text insert the table cell. I find that if I create the table by writing the html page manually, the table maintained its width of 200 and the text got wrapped round.
However if the table is generated through a servlet, the text flow out of the screen to the right.
22 years ago
I am using servlet to generate a table:-
out.println("<form>");
out.println("<table width=200>");
do something here......
out.println("</table>");
out.println("</form>");
Somehow the width=200 does not seem to work.
When I use pure html, it works perfectly.
Anybody has the same experience?
22 years ago
I have a date and time formatted as follows:-
Date = "2002-02-28"
Time = "14:15:00"
Date is formatted as yyyy-mm-dd and time is hh:mm:ss
How to add/minus X hours from the above date/time?
22 years ago
Placed the bean in a package and everything is OK now.
Why can't it work without package?
Thanks.
23 years ago
JSP
OK, realised my mistake (in fact its the mistake from the book). I altered the Fruit.java file and compiled it without problem. Place the class file in .....\webapps\root\web-inf\classes and run the jsp page (also corrected the code). Now I got the following error message:-
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\jakarta-tomcat-3.2.1\work\localhost_8080\_0002fgregory_0002fJSPsessions_0002fSession_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:60: Class gregory.JSPsessions.Session_00031_00032.Fruit not found.
Fruit orderedFruit = null;
^
C:\tomcat\jakarta-tomcat-3.2.1\work\localhost_8080\_0002fgregory_0002fJSPsessions_0002fSession_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:63: Class gregory.JSPsessions.Session_00031_00032.Fruit not found.
orderedFruit= (Fruit)
^
Now I am one step closer. Could it be my classpath setting? I have set the JAVA_HOME and TOMCAT_HOME parameters and pointed the PATH setting to the correct JDK folder (otherwise I would not be able to compile the java files). I have not made any setting to CLASSPATH.
I have not made any entry in the sever.xml or other related files.
Hmmmm..... Thought this would be easier than servlets. Got that working without a hitch.

Thanks guys.

[This message has been edited by Mark Leong (edited December 05, 2001).]
23 years ago
JSP
Made a mistake. My Tomcat version is 3.1 running on top of Win98.
The funny thing is even when I have deleted the bean (the class file), the same error is still reported. I believe I have not placed the bean in the correct folder.
At the moment I have placed the jsp and htm files in ..../webapps/root/myjsp.
The java, class files are placed in ...../webapps/root/myjsp/WEB-INF/classes.
My I do any setting to Tomcat to activate the bean?

Here are the files (htm, jsp, java):-
------------------------
<jsp:useBean id="orderedFruit" class="Fruit" />
<jsp:setProperty name="orderedFruit" property="fruitName" value="Mango" />
<jsp:setProperty name="orderedFruit" property="color" value="Orange" />
<jsp:setProperty name="orderedFruit" property="price" value="5.95" />
<jsp:setProperty name="orderedFruit" property="quantity" param="quantity" />

<html>
<body>
<h1>Your Fruit Order</h1>
<br><br>
Fruit: <jsp:getProperty name="orderedFruit" property="fruitName"/><br>
Color: <jsp:getProperty name="orderedFruit" property="color"/><br>
Price: $<jsp:getProperty name="orderedFruit" property="price"/><br>
Quantity: <jsp:getProperty name="orderedFruit" param="quantity" /><br>
Total:  $<%=orderedFruit.getPrice()*orderedFruit.getQuantity() %>
<br>
<p></p>
<a href="Listing12-3.jsp">Return to order form to adjust quantity</a>
</body>
</html>
--------------------------
public class Fruit {
private String fruitName;
private int quantity;
private String color;
private boolean isCitrus;
private float price;
public String getFruitName(){
return this.fruitName;
}
public void setFruitName(String name){
this.fruitName=name;
}
public int getQuantityInPounds(){
return this.quantity;
}
public void setQuantityInPounds(int quantity){
this.quantity=quantity;
}
public String getColor(){
return this.color;
}
public void setColor(String color){
this.color=color;
}
public float getPrice(){
return this.price;
}
public void setPrice(float price){
this.price=price;
}
public boolean isCitrus(){
return this.isCitrus;
}
public void setCitrus(boolean isCitrus){
this.isCitrus=isCitrus;
}
}
-------------------------------
<html>
<body>
<h1>Fruit Order Form</h1>
Fruit: Mango<br>
Color: Orange<br>
Price Per Pound: $5.95 <br>
<form action="confirm.jsp" method="post">
Number of pounds: <input type="text" name="quantity"><br>
<input type="submit" value="Order Fruit">
</form>
</body>
</html>
-----------------------------
There is also something very weird. Initially I have made a test jsp page in ..../webapps/test. I delete the folder completely and restarted Tomcat. However when I tried to load the jsp page, it loaded!! Can I delete files in the <tomcat-install>\work folder?
23 years ago
JSP
I am starting to learn about using Java Beans.
I copied some Java Bean codes from a book and compiled the .java file to a .class file. No problem.
Placed the .class file in ....\webapps\root\myjsp\WEB-INF\classes folder. The JSP files are in ....\webapps\root\myjsp.
When I tried to call the bean, I got the following error:
org.apache.jasper.JasperException: getProperty: Mandatory attribute property missing
at org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:202)
at org.apache.jasper.compiler.Parser$GetProperty.accept(Parser.java:677)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1073)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:182)
at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:149)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java:484)
I have checked the code and am very sure I have copied it to the letter. I am using Tomcat 3.2.1 in Win 98.
Thanks in advance for your advise.
23 years ago
JSP
You certainly can. You can view an example at the following site:
http://www.webappcabaret.com/justtalk/servlet/smallcon.justtalk.userlogin

If you are using Netscape or other browers, might have some problems. I do not have time to debug yet. Seems to be OK with IE which I have used to develop in (mistake).
23 years ago
Since we are talking a little about Javascript here, I wonder if somebody can help me with this problem:-
When a page is loaded, I added the following javascript to open as new window:-
newwindow = window.open("some.htm", "somenewwindow");
However before executing the statement, is it possible for me to check if "somenewwindow" is opened? I tried the following but it does not work as the window has not been created when the "if" statment is first executed.
if (somenewwindow == null){
//open the new window
} else {
//do not open
}
23 years ago
If http://127.0.0.1:8080 works (tomcat page shown) then it is likely that tomcat is OK. The rest of the errors were probably due to classpath error.
23 years ago