myapp/index.jsp is throwing a NPE and returns a 500 error, causing the
problem you see in application.jsp. You should look at why
myapp/index.jsp is throwing a NPE (NullPointerException).
--David
Pedro Santa wrote:
Hi all!
I'm getting an error while trying to parse a JSP from a bean. Here's the deal.
My site has 2 frames. On the first is the web page. The second one, I
want it to parse the contents of the first frame, in order to strip
some elements from the source code - but for testing purposes I now
only want to echo the entire source on the second frame.
To do this I've got a bean named Reader.java (package "reader") that
has a property 'url' to store the filename of the page I want to parse
and methods to set the url and to get the source of the url in a
String. Here's the code for the getSource method:
public String getSource() {
String result = "";
try {
URL urlobj = new URL("http://localhost:8080/myappfolder" + url);
System.out.println("###### URL: " + urlobj.toString());
BufferedReader in = new BufferedReader(new
InputStreamReader(urlobj.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
result += inputLine + "\n";
}
in.close();
} catch (IOException ex) {
System.out.println("### ERROR!");
Logger.getLogger(Reader.class.getName()).log(Level.SEVERE,
null, ex);
}
return result;
}
I use the Reader.java bean on the HTTP, session and when a page loads
updates the 'url' property of the bean.
The second frame is an application.jsp that reloads every 5 seconds,
and outputs the String from the Reader.java getSource method.
I pasted the all my jsp's on the
<tomcat_folder>\webapps\ROOT\myappfolder - as well as the context.xml
and web.xml files generated by Netbeans 6, the entire contents of
'web' folder. Pasted also all my classes on
<tomcat_folder>\webapps\ROOT\myappfolder\WEB-INF\classes and
<tomcat_folder>\webapps\ROOT\WEB-INF\classes.
When I try and fire up the page, the second frame displays nothing and
I get this error on Tomcat console: http://rafb.net/p/5auMCE76.html
I've tested the code with simple html files and it worked fine. I
tested the code with a jsp file without dynamic code (only HTML) it
worked fine either. And finally testes the code with the default jsp
for tomcat (http://localhost:8080/index.jsp) that has dynamic code in
it and it worked flawless as well.
I think I'm not doing something here, can anybody give me some advice
on how to put this thing to work?
I send also some useful information.
The application.jsp:
<[EMAIL PROTECTED] import="reader.*" %>
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="5; URL=application.jsp">
<%
HttpSession s = request.getSession();
Reader reader = (Reader) s.getAttribute("reader");
%>
<title>JSP Page</title>
</head>
<body>
<%
out.print(reader.getSource());
%>
</body>
</html>
I'm using Windows XP Professional SP2, Jakarta Apache Tomcat 5.5.9
(downloaded from here
http://archive.apache.org/dist/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9.exe)
and NetBeans IDE 6.0 Beta 2 (Build 200710212201).
All the other JSP features work fine.
:)
Thanks in advance.
Cheers.
Pedro Machado Santa
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]