Hi folks,
I have a question about the optimum approach for using
JSP+data access bean to generate customized HTML. I have a feeling that
alot of the problems I'm trying to solve right now will be addressed in JSP 1.1,
whenever that finally rolls around. In the meanwhile, I'm using JSP's in a
very simple way: I have a set of basic HTML files, where some of the content of
the HTML files is stored in a database. I have a bean that I call
Getfields that can access a given "variable" from the database.
So, for my index.html document (index.jsp in this cas), I use the following JSP
code to extract the title:
<TITLE>
<%= getfields.getfield("indextitle") %>
</TITLE>
<%= getfields.getfield("indextitle") %>
</TITLE>
Ideally, I'd like the code to look like:
<TITLE><VARIABLE indextitle></TITLE>. First question: is
JSP 1.1 supposed to be able to do this? Allow me to substitute little
snippets of code for tags?
Now I'm trying to write a servlet that will allow me to
customize the values for all of the fields that a given JSP file calls.
So, for example, I want the servlet to read my index.jsp file, see that it
references a variable called "indextitle", and then provide me a form
to change its value. If I was using tags, this would be a simple process
of parsing for that individual VARIABLE tag. But since I'm not, my second
question is: is there an easy method or technology for doing what I'm trying to
do? I read a bit about XML to try to introduce my custom tag, but it
seemed like serious overkill for what I'm trying to do. Opinions? Is
there some simple hack-method I can use to introduce a tag for my parser to look
for while I'm waiting for JSP 1.1?
I could just write a more robust parser that looked for JSP
code and then looked for calls to my getfields method, but it just seems rigid,
and will probably get thrown away in the future anyway.
Any suggestions are greatly appreciated!
-Richard
