Help with JSP

SinNisTeR

Diamond Member
Jan 3, 2001
3,570
0
0
I setup both tomcat and java web server 6.1. Using both for testing. Which is better?

Second, I compile a test class and put class file under web-inf/classes but i still cannot access them in my jsp page. I guess i need to do something with the web.xml file. I thought this had to do with servlets, but I dont want to use those right now. I just want to use methods of the class files i create.

I also heard that the beans get cached into memory, so any change in them would require a restart of the server. Anyway around this?

I also heard about .war files. Is there a simple way to make them? what is the file manifest.mf.

Why is this all confusing? i just want to make a class and use it in a webpage. This is harder than pulling teeth. I am not really concerned about servlets at the moment. Ill work on learning them after i have the basics down.

edit: also how to i install a mysql driver to be able to use them in jsp?

Please help me!
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: SinNisTeR
I setup both tomcat and java web server 6.1. Using both for testing. Which is better?
I've never used java web server before so I won't comment on it's quality. Is it from Sun? Tomcat is far and away the most common servlet container, especially in the open source world and it is of very good quality. You will probably have a much easier time getting help for it.
Second, I compile a test class and put class file under web-inf/classes but i still cannot access them in my jsp page. I guess i need to do something with the web.xml file. I thought this had to do with servlets, but I dont want to use those right now. I just want to use methods of the class files i create.
Some details about the class? Is it in a package? Is it in any subdirectories of WEB-INF/classes? (make sure you use the uppercase properly). I believe your class must be in a package other than the default to be useable from a jsp. Also, have you done the <%@ page import %> properly?
I also heard that the beans get cached into memory, so any change in them would require a restart of the server. Anyway around this?
Depends on the scope you put them at. For request scope they get blown away after every request. For session scope they get removed after the user logs out or his/her session times out. For application scope they stick around until you stop or restart the application which you can do without restarting the server. Application scope is not usually a good thing though, since you have to be careful about threading. You can change them all you want, they're just normal java objects.
I also heard about .war files. Is there a simple way to make them? what is the file manifest.mf.
war files are just your web app directory structure in a zip file with the .war extension. META-INF/manifest.mf is not required but will often be generated automatically if you use the jar executable to build the war (or the jar ant task). They just provide some extra info about the war/jar which you don't really need to worry about for now. To deploy a war you just drop it into the webapps directory (at least for Tomcat) and it will be unpacked and deployed automatically. It's semantically identical to just your webapp directory so there's not much point in using it for development, just if you want to send the whole app to be deployed on someone elses server.
Why is this all confusing? i just want to make a class and use it in a webpage. This is harder than pulling teeth. I am not really concerned about servlets at the moment. Ill work on learning them after i have the basics down.
Hang in there :)
edit: also how to i install a mysql driver to be able to use them in jsp?

Please help me!
Just take the jar file and put it somewhere on the classpath. If you're using it completely internally to your web app, putting it in WEB-INF/lib should be good enough (I'm assuming you know how to use it once it's been deployed). Another frequent configuration is to have Tomcat supply a connection factory via jndi (a much better solution for scalability and database independance) and for that you can put it in tomcat's common/lib directory (that'll also work if you just want to use it on your own).

Hth, come back with any more questions you have :)

Edit: speling grammar fixing and
 

Stuxnet

Diamond Member
Jun 16, 2005
8,392
1
0
Kamper is right... just hang in there. The most difficult thing about Java, in my opinion, is getting a handle on the tools. The language itself is relatively easy... it's the rest of the stuff that can be overwhelming ;) .