Okay, so I know this is in the first chapter of whatever JavaRanch recommended book I read on
JSP long ago, but I haven't written any JSP (or
Java for that matter) in a long time, so I can't remember how to do this.
So far this is what I have done:
Installed
Tomcat
Installed MySql
Made a DB
Wrote an HTML page to send data to a JSP
Got those values in the JSP
Queried the database with those values
Got output
Displayed it
This all works great, but the code is really ugly. Now I want to put that database access code into a class file. That way it's not clogging up my JSP. I have a vague recollection of how to do this, but can't remember exactly. I think what you are supposed to do is something like this.
Make a java file
Compile it (?)
Put the .class into a jar (or the .java?)
Put the .jar into a directory (WEB-INF? WEB_INF/classes?)
Import the .jar
Is that right? Exactly how is this done? Where is the jar supposed to go? Is there an example of this somewhere I can try to get working minimally before I start messing with my already written code? It would be nice to see a tutorial that gives you an itty-bitty JSP that imports a class that just returns a
string so that the JSP can print it, and shows you how to jar everything up and where to put each piece of the code.
Can someone explain this or point me at a good reference? Everything I have seen so far just confuses me more.
Thanks!