tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Brown" <dwbr...@webitplanet.com>
Subject Re: jasper.error.emptybodycontent.nonempty, MySQL
Date Mon, 25 Nov 2002 13:01:45 GMT
Eric Earnst writes: 

> Hi all,
> I've read a lot of docs but over a long enough period of time that I
> forget most of what I read, the recent over-age newbie really applies
> here... 
> 
> I am putting together my first site and am getting the following error
> message from Tomcat (4.1.12-LE-jdk14):
> org.apache.jasper.JasperException: /pnDatabaseConnect.jsp(3,0)
> jasper.error.emptybodycontent.nonempty 
> 
> Here is the top of the file in question: 
> 
> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
> <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %> 
> 
> <sql:setDataSource>
> 	var="PartNumDB" scope="application"
> 	driver="org.gjt.mm.mysql.driver"
> 	url="jdbc:mysql://localhost:3306/PartNumberMaster"
> 	user="Root"
> 	password=""
> </sql:setDataSource> 
> 
> <sql:query var="PartNum" scope="request" datasource="${PartNumDB}">
> 	SELECT * FROM PartNumberMaster
> </sql:query> 
> 
> I don't have a web.xml file, every one I've come up with causes Tomcat
> to not find my pages...  I've loaded the JSTL into:
> C:\Jakarta\jakarta-tomcat-4.1.12-LE-jdk14\webapps\myapp\WEB-INF\lib
> and the TLD files into the WEB-INF directory. 
> 
> Thanks,
> Eric 
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org> 
> 
 


Hello Eric, i will have to admit that i'm using a tc version < 4.1.12 but i 
cannot fathom tc w/o a web.xml file. if u r a newbie then u r taking leaps 
that r too big. u have crammed a lot of functinality into a jsp using the 
tags. this is ok 4 someone w/ a lot of background but i personally don't 
recommend this approach. 4 the time being if u r interested in the 
functionality and not the implementation then allow me to suggest that u 
take a more "tiered" approach to make ur jdbc connection and sql query:
1) lay off the tags untill u r more experienced.
2) what i mean by "tier" is put ur jdbc connection and sql query in a 
separate class or "bean" away from ur web content directory. i use oracle 
and mysql all the time this way. get the class bean to execute standalone 
first b4 u put it into ur directory structure. an ascii directory tree 
follows.
3) inspect ur build process. using ant and bulid.xml is highly recommended.
4) if u get step two above to work (separating ur web content from ur 
process) then allow me to suggest introducing a third leg (in technogeek 
this is MVC: model-view-controller). this third piece is a servlet or better 
yet a "director" servlet that handles all requests from all of ur jsp's (1 
to serveral jsp's). case in point: ur jsp requests ur servlet for db info. 
the servlet requests info from ur class "bean". the servlet sends the db 
info and sql query results back to the jsp. in the long run much simpler and 
cleaner not to mention the ability to scale this "design pattern" (more 
technogeek). an example of my directory structure follows: 

$TOMCAT_HOME
          |
          /webapps
                 |
                 /<app_dir>
                          /WEB-INF
                                 |
                                 /web.xml 

$TOMCAT_HOME
          |
          /webapps
                 |
                 /<app_dir>
                          /WEB-INF
                                 |
                                 /classes
                                        |
                                        /<app_dir>
                                             /\
                                            /  \
                                           /    \
                                         /web  /beans 

this is just one director. i have the directory separated to show the 
different file contents: web.xml is always under /WEB-INF. under /web 
contains: jsp's, html's, css's, etc. and under /beans contains: ordinary 
class files w/ constructors and getter/setter methods 4 ur web objects. 
also, the /beans directory or yet another aply named directory could 
contained serialized classes 4 even more advance data movement. 

this is the classic design pattern most developers have at least some 
familiarity: http://java.sun.com/blueprints/patterns/ or better yet just 
type: model-view-controler at the google prompt and start reading. 

hope this helps, david.

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message