beans tomcat 101

V

vbhelpski

Hi. I'm a java/perl programmer of sorts. I'm trying
to get a handle on JSP. Soooo I spun up
Tomcat and mySql.


Here's my present "manifest"


jdk 1.5


tomcat 5.5.4


mysql 4.1.9


MySQL® Connector/J 3.1.6


w2k, ie6


I can write (ripoff) java/jps code to connect to and use the mysql
data base Now I want to try the bean thing. Are there beans
already installed in the tomcat? How, where, do I collect and
install some beans to play with? If they are installed how do I
browse them?

thanks
 
R

Ryan Stewart

[...]
I can write (ripoff) java/jps code to connect to and use the mysql
data base Now I want to try the bean thing. Are there beans
already installed in the tomcat? How, where, do I collect and
install some beans to play with? If they are installed how do I
browse them?
You misunderstand. A "bean" (typically) is a simple Java class that holds
information. A user bean might look like this:
public class User {
private String name;
private int fingers;

public void setName(String name) {
this.name = name;
}

public String getName() {
return this.name;
}

public void setFingers(int fingers) {
this.fingers = fingers;
}

public int getFingers() {
return this.fingers;
}
}
 
V

vbhelpski

Yah, I get that. I guess the question really is how do
you install classes in or allow access from the jsp container to
these new classes. Do you just lay them down in a class directory?
Isnt' there some special kind of 'registration'?
Thanks

Ryan said:
[...]
I can write (ripoff) java/jps code to connect to and use the mysql
data base Now I want to try the bean thing. Are there beans
already installed in the tomcat? How, where, do I collect and
install some beans to play with? If they are installed how do I
browse them?
You misunderstand. A "bean" (typically) is a simple Java class that holds
information. A user bean might look like this:
public class User {
private String name;
private int fingers;

public void setName(String name) {
this.name = name;
}

public String getName() {
return this.name;
}

public void setFingers(int fingers) {
this.fingers = fingers;
}

public int getFingers() {
return this.fingers;
}
}
 
R

Ryan Stewart

*fixed top post*
Ryan said:
You misunderstand. A "bean" (typically) is a simple Java class that holds
information. A user bean might look like this:
[...]
Yah, I get that. I guess the question really is how do
you install classes in or allow access from the jsp container to
these new classes. Do you just lay them down in a class directory?
Isnt' there some special kind of 'registration'?
Thanks
Ah, I see. When working with web applications, you create a directory named
"WEB-INF" and put it at the top level of your application's directory structure.
The specification requires that this folder and its contents never be accessible
to the client. In other words, WEB-INF and everything in it are visible only to
the server. One thing that goes in WEB-INF is a directory named "classes". This
is where all supporting Java classes go, as well as anything else that your
application needs to be on the classpath. Not JARs though; those go in a
separate subdirectory of WEB-INF named "lib". In order to use classes in a web
application, they should all be packaged somewhere besides the default package.
So let's say you have a class Bar in package com.foo. Just like with other Java
applications, the class file would go inside a directory named "foo", which
would go in a directory named "com", and the com directory should go in
"classes". That will allow the rest of your web application to find your class
files. To import a class into a JSP, (I assume you are using scriptlets) use the
page directive:
<%@ page import="com.foo.Bar" %>

You can include multiple imports:
<%@ page import="com.foo.Bar, java.util.*" %>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top