Re: JSP Compile in Ant with Tomcat 5.0.16

2003-12-11 Thread Larry Karnowski
All,
I've disovered the cause of my problems with the Ant build using the 
JspC task.  I'm documenting the workaround here for anyone else having 
similar problems.

I thought that the JSP Ant build was successful even though I was seeing 
errors with runtime compilation in Tomcat because Ant was reporting a 
BUILD SUCCESSFUL.  However, after checking the generated *.java files, I 
found that the same files that were causing Tomcat to fail were also 
failing in Ant, only quietly.  The JspC task was creating zero-length 
Java files that Javac was then quietly ignoring.  This is because of two 
problems below:

1) Apache bug #25452 
((http://issues.apache.org/bugzilla/show_bug.cgi?id=25452), where the 
Ant build is not notified if there are any JspC compile issues.  Instead 
it creates zero-length Java files.

2) I didn't have my commons-logging-api configured correctly.  I 
strongly recommend adding the following to your Java command in your Ant 
shell script to ensure proper error logging during JSP compiles:

-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog 
-Dorg.apache.commons.logging.simplelog.defaultlog=info 
-Dorg.apache.commons.logging.simplelog.showdatetime=true

These properties will tell JspC to use the SimpleLog class which sends 
its log messages to stderr.  You might still get a BUILD SUCCESSFUL 
report from Ant, but a human can look back through the build output and 
see any error messages.  Also, you can do a check for empty Java files. 
 (example "find builddir -name \*.java -empty")

I hope this helps, and thanks to Rémy for looking!
Larry Karnowski
Remy Maucherat wrote:
Larry Karnowski wrote:

All,
I'm getting error messages while compiling JSPs at runtime inside 
Tomcat but not when I compile the same JSPs with the  Ant task.

I've upgraded my Ant build to use the new  tag (the 
org.apache.jasper.JspC class) instead of the old  tag that came 
with Ant.  (It doesn't work with Tomcat 5.0.16.)  All my JSPs compile 
fine with the new class.


 and  are the same, as long as the task classname is the 
same :) So you should be able to rename jasper2.

However, when I actually put the JSPs in my webapp for Tomcat to 
compile, I get a few compilation errors.  Note that I'm compiling my 
JSPs as a quality assurance step, not to ship precompiled Java classes. 


This is a very good practice. It does allow detecting many trivial 
errors much faster.

 I'm trying to find errors at build time rather than run time.

The problem comes with a poorly-coded JSP include action like this:



I'll be the first to admit this is poor style, and I'm not too upset 
that Tomcat won't compile it.  I can easily fix it by removing the 
trailing tag and making it an empty tag.  However, my normal method of 
finding these types of errors is failing me -- my Ant JSP build.


Standard JSPs are not XML. Maybe that's the problem. You should post the 
error you're getting, BTW.

This is my build.xml snippet:

This is the error message I get from Tomcat:
Expected "param" tag with "name" and "value" attributes
I've started combing through the Jasper code to find what's different 
when compiling inside Tomcat as opposed to inside Ant.  I've looked 
through all the top-level Jasper wrappering code that gathers the 
compilation options, but nothing seems significantly different.  None 
of the compile options seem to be relevant to this issue.

There must be something going on deeper in the actual JSP compilation 
code.  Does anyone have any idea what's happening?




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


JSP Compile in Ant with Tomcat 5.0.16

2003-12-09 Thread Larry Karnowski
All,
I'm getting error messages while compiling JSPs at runtime inside Tomcat 
but not when I compile the same JSPs with the  Ant task.

I've upgraded my Ant build to use the new  tag (the 
org.apache.jasper.JspC class) instead of the old  tag that came 
with Ant.  (It doesn't work with Tomcat 5.0.16.)  All my JSPs compile 
fine with the new class.

However, when I actually put the JSPs in my webapp for Tomcat to 
compile, I get a few compilation errors.  Note that I'm compiling my 
JSPs as a quality assurance step, not to ship precompiled Java classes. 
 I'm trying to find errors at build time rather than run time.

The problem comes with a poorly-coded JSP include action like this:



I'll be the first to admit this is poor style, and I'm not too upset 
that Tomcat won't compile it.  I can easily fix it by removing the 
trailing tag and making it an empty tag.  However, my normal method of 
finding these types of errors is failing me -- my Ant JSP build.

This is my build.xml snippet:

This is the error message I get from Tomcat:
Expected "param" tag with "name" and "value" attributes
I've started combing through the Jasper code to find what's different 
when compiling inside Tomcat as opposed to inside Ant.  I've looked 
through all the top-level Jasper wrappering code that gathers the 
compilation options, but nothing seems significantly different.  None of 
the compile options seem to be relevant to this issue.

There must be something going on deeper in the actual JSP compilation 
code.  Does anyone have any idea what's happening?

Thanks,
Larry Karnowski
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: HTTP response header displayed for JSP

2003-11-05 Thread Larry Karnowski
Howard,
Strangely enough, I'd never seen the HTTP headers display raw in a page 
like that until today.  We were having a problem (unrelated, very 
specific to our environment) where some junk was being spit out BEFORE 
the headers (again, not a Tomcat issue but a proxy issue).  You might 
want to debug your raw servlet/JSP output by telnetting directly to the 
server or sniffing the packets with tcpdump or the like.  Something 
somewhere might be gumming up your output.

Good luck,
Larry Karnowski
On Nov 5, 2003, at 2:55 PM, Howard Lin wrote:

When trying to fetch a simple JSP page, the following header displayed 
on the browser (IE 6.0 on WinXP):

HTTP/1.1 200 OK Content-Type: text/plain;charset=ISO-8859-1 
Content-Length: 2183 Date: Wed, 05 Nov 2003 19:42:16 GMT Server: 
Apache Tomcat/4.1.29-LE-jdk14 (HTTP/1.1 Connector)

After click the refresh button, the text displayed correctly. But if I 
click the refresh button again, the above header displayed again.

I searched the archive and google and couldn't find anything useful. I 
also changed some cookie settings in IE and that didn't fix either. 
The tomcat server is running standalone on a Linux RedHat 9.0 box with 
j2sdk 1.4.2.

Howard

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: ?

2001-02-20 Thread Larry Karnowski

What I do is define a static utility function somewhere like this:

/**
 * Return a string that represents the fully qualified URL
 * for our servlet context, suitable for use in the HTML
 * base tag.
 *
 * As an example, suppose your host was www.mycompany.com,
 * you are serving from port 80, and your web application name
 * was "opennms," then this method would return:
 * http://www.mycompany.com:80/opennms/
 *
 * @param request the servlet request you are servicing
 */
public static String calculateUrlBase( HttpServletRequest request ) {
if( request == null ) {
throw new IllegalArgumentException( "Cannot take null
parameters." );
}

StringBuffer buffer = new StringBuffer();

buffer.append( request.getScheme() );
buffer.append( "://" );
buffer.append( request.getServerName() );
buffer.append( ":" );
buffer.append( request.getServerPort() );
buffer.append( request.getContextPath() );
buffer.append( "/" );

return( buffer.toString() );
}

Then, in my JSP html header, I do this:

  


Not the prettiest solution, especially since you have to add that ugly line
to every JSP, but maybe someone will add a standard JSP action for
calculating this in the future.  I thought about adding a custom taglib for
doing this, but writing a static method was simpler.

Larry Karnowski
[EMAIL PROTECTED]
http://www.opennms.org/


- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 20, 2001 2:00 PM
Subject:  ?


> Yo,
> a quick and simple question:
> is there a configuration option that adds a base tag to the jsp pages ?
> if there is, where is it ?
>
> TIA,
>
> Sloot.
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]