JSP and JSTL Tutorials - Tutorial Addendum - Bobcat 4.1.18 with JDK 1.4.1
| |
(Continued from antecedent part...)
You will get the afterward accumulation absurdity adage CacheBean is not resolvable:
org.apache.jasper.JasperException: Clumsy to abridge chic for JSP
An absurdity occurred at line: 7 in the jsp file: /jsp/UseBeanModified.jsp
Generated servlet error:
[javac] Accumulation 1 antecedent file
D:localjakarta-tomcat-4.1.18workStandalonelocalhost
\_jspUseBeanModified_jsp.java:43: cannot boldness symbol
symbol : chic CacheBean
location: chic org.apache.jsp.UseBeanModified_jsp
CacheBean b = null;
^
The absolute couldcause of this absurdity is not the compiler. It is the Bobcat accumulation environment.
Because you can abridge the adapted class, UseBeanModified_jsp.java, accurately in a command window
with the aforementioned chic paths acclimated by the Bobcat environment.
The alone advantage larboard to use a JavaBean with Bobcat 4.1.18 and JDK 1.4.1 is to make your
JavaBean in a called package. The next area will accord you an example.
JavaBean in a Called Amalgamation - TempratureConvertorBean.java
Creating JavaBean classes in called bales is actual simple, just add a amalgamation
declaration account at the alpha of the class. The afterward archetype shows
you a JavaBean classe authentic in a amalgamation called as "":
/**
* TempratureConvertorBean.java
* Absorb (c) 2003 by Dr. Yang. All rights reserved.
*/
package ;
public chic TempratureConvertorBean {
clandestine bifold celsius = 0.0;
clandestine bifold fahrenheit = 32.0;
accessible bifold getCelsius() {
acknowledgment celsius;
}
accessible abandoned setCelsius(double c) {
celsius = c;
fahrenheit = 1.8*c + 32.0;
}
accessible bifold getFahrenheit() {
acknowledgment fahrenheit;
}
accessible abandoned setFahrenheit(double f) {
fahrenheit = f;
celsius = (f-32.0)/1.8;
}
accessible Cord getInfo() {
acknowledgment new String("My TempraturConvertorBean - Adaptation 1.00");
}
}
Compile this antecedent code, and archetype the chic book to the Bobcat chic path.
Remember to abundance the chic book beneath a sub agenda called as "".
>localj2sdk1.4.1injava TempratureConvertorBean.java
>copy TempratureConvertorBean.class
localjakarta-tomcat-4.1.18webapps
ootweb-infclasses
Now we are accessible to analysis this JavaBean with an JSP page, TempratureConvertor.jsp:
<?xml version="1.0"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<!-- TempratureConvertor.jsp
Absorb (c) 2003 by Dr. Yang
-->
<jsp:directive.page contentType="text/html"/>
<html><body>
<jsp:useBean id="b">
<jsp:expression>b.getInfo()</jsp:expression><br/>
Setting acreage "fahrenheit" to 70.0.<br/>
<jsp:setProperty name="b" property="fahrenheit" value="70.0"/>
Getting acreage "celsius" back:
<jsp:getProperty name="b" property="celsius"/>
<br/>
</body></html>
</jsp:root>
Open this JSP page with IE, you will get:
My TempraturConvertorBean - Adaptation 1.00
Setting acreage "fahrenheit" to 70.0.
Getting acreage "celsius" back: 21.11111111111111
It works! Agenda that there is no charge to use the acceptation statement, if you use the
fully able chic name in the jsp:useBean activity element.
Conclusions:
- Using JavaBean classes in bearding bales with Bobcat 4.1.18 and JDK 1.3.1
requires acceptation charge elements in the JSP pages.
- There is no way to use JavaBean classes in bearding bales with Bobcat 4.1.18
and JDK 1.4.1.
- There is no problem using JavaBean classes in called bales with Bobcat 4.1.18
and JDK 1.4.1.
|
class, tomcat, javabean, celsius, fahrenheit, property, double, named, public, tempratureconvertorbean, package, error, packages, version, classes, usebeanmodified, cachebean, return, , < jsp, javabean classes, packages with, property celsius, html <, jsp page, property fahrenheit, packages with tomcat, unnamed packages with, property celsius back, getting property celsius, tutorials tutorial notes, tutorial notes tomcat, jstl tutorials tutorial, |
Also see ...
This affiliate explains:How to amount a JavaBean into JSP pages and dispense its properties. Compilation issues of using JavaBean classes in bearding packages.Setti
i(Continued from antecedent part...)/iIt s actual absorbing to see the Servlet chic translated from UseBean.jsp: package org.apache.jsp;import javax.servlet.*;import javax.
i(Continued from antecedent part...)/iIn this section, let s attending at some of the basal rules about ambience and gettingJavaBean properties:The setProperty aspect haveto be accura
i(Continued from antecedent part...)/iNote that:Property names are case sensitive. Acreage name "Author" can not be mapped to "getAuthor" method. Two set method
i(Continued from antecedent part...)/iUsing Java Altar as JavaBeansNow we understand that a JavaBean is just a accustomed Java item with some distinctively namedp