Jo Lee

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

Recent posts by Jo Lee

I find the problem. One of the required int paremeter is missing from one of the links
After I fixed it, it all works now. One of the String parameter has a space missing.
Thanks again
19 years ago
JSP
Thanks Anthony;
I doubled checked the spaces, there is no extra spaces. Another funny thing that it seems other of my java program can not handle Integer.parseInt any more. If I use Integer.parseInt(string), I get a number format exception. It not only occur on one of my computer, it occurs on both of them.
I am really lost.
19 years ago
JSP
in my jsp pages, I use url to pass some integer parameters.
such as code=5
simple enough
But when the second page try to retrieve that number by
Integer.parseInt(request.getParameter("code"));
it gives me a NumberFormatException.
It only happens on some cases, for example, if I have code=5 and anthcode=6, only code=5 will give me an exception, but anthcode=6 does not.
I deleted the files in the tomcat-4.0.4's directly and restarted tomcat multiple times, and check double checked the difference between code=5 and anthcode=6, I am pulling my hair at the moment by this mystery.
Any help is really appreciated.

Thanks a zillion
Lee
19 years ago
JSP
I did a search on google and javaranch about this classcastexception, it seems it is a problem, however, is there a solution?
I have this problem now, when I try to pass a Map object as session Attribute, even if I do not do that, it seems that if I just use the Map object in the jsp page and when I try to reload the page, it gives classcastexception, I use tomcat4.0.4
Any more pointer or solution is highly appreciated.
thanks
19 years ago
JSP
thanks Bill;
I created the following error page:
<%@page contentType="text/html"%>
<%@ page isErrorPage="true" %>
<html>
<head><title>JSP Page</title></head>
<body>
<p> mypage reported the following error</p>
<%= exception %> this problem occured in the following place;
<pre><% exception.printStackTrace(out); %></pre>
</body>
</html>
The compiler complains that :
error$jsp.java [76:1] cannot resolve symbol
symbol : method printStackTrace (javax.servlet.jsp.JspWriter)
location: class java.lang.Throwable
exception.printStackTrace(out);
^
1 error
while running in tomcat -4.0.4 , it complains;
An error occurred at line: 10 in the jsp file: /error.jsp
Generated servlet error:
C:\jstlPackage\work\Standalone\localhost\MySite\error$jsp.java:70: Incompatible type for method. Can't convert javax.servlet.jsp.JspWriter to java.io.PrintWriter.
exception.printStackTrace(out);
^
However, when change the error page with the following line;
<% exception.printStackTrace(new PrintWriter(out)); %>
I get the following compiler error:
error$jsp.java [76:1] cannot resolve symbol
symbol : class PrintWriter
location: class org.apache.jsp.error$jsp
exception.printStackTrace(new PrintWriter(out));
^
1 error
and the folloing tomcat error:
An error occurred at line: 10 in the jsp file: /error.jsp
Generated servlet error:
C:\jstlPackage\work\Standalone\localhost\MySite\error$jsp.java:70: Class org.apache.jsp.PrintWriter not found.
exception.printStackTrace(new PrintWriter(out));
^
if change to the following;
<% exception.printStackTrace(new JspWriter(out)); %>
I get another compiler error:
error$jsp.java [76:1] javax.servlet.jsp.JspWriter is abstract; cannot be instantiated
exception.printStackTrace(new JspWriter(out));
^
1 error

I am completely lost in the mist. Need urgent help.
Jo
19 years ago
JSP
I have a class method which returns an arraylist. In my jsp page I used java.util.ArrayList aList = thisclass.getList();
and then iterate it through to create a table of data display. This page comes up after the user validation is done.
when I run the jsp page first time, it all runs ok. However, if I try to click on a link to the same jsp page from another page, it will return an Http status 500 error with ClassCastException.
Hope I have made this clear.
Jo
19 years ago
JSP
I have tried the servlet gotopage method by Maha, here is the method;
ServletUtilities.gotoPage("/Accounts/list_deputations.jsp",getServletContext(),request,response);public static void gotoPage(String address,ServletContext context,HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {RequestDispatcher dispatcher = context.getRequestDispatcher(response.encodeURL(address));System.out.println("Dispatch forward to ="+address);dispatcher.forward(request,response);}
I get the following error
java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:205)
at ServletUtilities.gotoPage(ServletUtility.java:81)
the same redirection request works with response.sendRedirect("/Accounts/list_deputations.jsp");
I double checked my tomcat4.0.4 setup with this url:http://www.moreservlets.com/Using-Tomcat-4.html#Servlet-Reloading
Why? and how to solve it?
19 years ago
I am now a bit confused about this as well. So in order to use the pageContext.getAttribute("something"); in some other pages, we have to use pageContext.setAttribute() first in order for it to be retrievable. How is this differ from session.setAttribute() besides the scope difference?
Jo
19 years ago
thanks for your help.
I get it sorted now.
19 years ago
Thanks very much.
I downloaded the zip file and it worked.
How do one use the war file? do I put it in the webapps/classes and add that to the path?
Jo
19 years ago
JSP
What do I have to modify in tomcat 4.0.4 's confiruation file in order to use jstl tags?
I tried to run the example from Shawn Bayern's book scroll.jsp from chapter 5(listing 5.1, I get a blank screen.
When trying to compile the file from Forte for Java 4, community edition, I get the following error:
"This absolute uri (http;//java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application"
Your help is highly appreciated
Jo
19 years ago
JSP
could any body help please!!
I am lost.
Jo
19 years ago
I am trying to read a bolb data from database to a string using the following code:
InputStream bst = rs.getAsciiStream(1);
BufferedReader reader = new BufferedReader(new InputStreamReader(bst));
StringBuffer sbuff = new StringBuffer();
int c;
String longString="";
try{
while ((c = reader.read ()) != -1){
sbuff.append(reader.readLine());
longString = sbuff.toString();

}
System.out.println(longString);
}catch(IOException e){}

When longString is printed out, it prints out all the characters but the very first one? Why?
Jo
19 years ago
Hi,
Thanks for the information. I did not do the modification on server.xml . Now I have done it and tried the sample servlet from the instruction, it worked beautifully.
Thanks again.
Jo
19 years ago
Sorry, instead of writing a response, I wrote a new topic by mistake.
I have tried all the suggestions, and it still says that servlet not found.
Is there any trick about tomcat install? May be my tomcat server is not configured right? I am using tomcat-4.0.4
Jo
19 years ago