Link to home
Start Free TrialLog in
Avatar of yccheok
yccheok

asked on

bean class code embended in JSP page wont work

i am using Sun Java System Application Server.

i found that my bean class code that embended in JSP page wont work,
--------------------------------------------------------------------------
<HTML>
<jsp:declaration>
// this is a local "helper" bean for processing the HTML form
static public class localBean
{
private String value;
public String getValue() { return value;}
public void setValue(String s) { value = s; }
}
</jsp:declaration>
<jsp:useBean id="localBean" scope="application" class="localBean" >
<%-- Every time we create the bean, initialize the string --%>
<jsp:setProperty name="localBean" property="value" value="World" />
</jsp:useBean>
<%-- Whatever HTTP parameters we have,
try to set an analogous bean property --%>
<jsp:setProperty name="localBean" property="*" />
<HEAD><TITLE>HelloWorld w/ JavaBean</TITLE></HEAD>
<BODY>
<CENTER>
<P><H1>Hello
<jsp:getProperty name='localBean' property='value'/></H1></P>
<FORM method=post>
Enter a name to be greeted:
      <INPUT TYPE="text" SIZE="32" NAME="value"
VALUE="<jsp:getProperty name='localBean' property='value'/>">
<BR>
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
</CENTER>
</BODY>
</HTML>
--------------------------------------------------------------------------
i need to explicitly create a C:\Learning\JSP\WEB-INF\classes folder, extract out the embended bean code from JSP page, compile it to class file and put it in the previous folder that created explicitly. then only it will work.

may i know how can i keep continue to make the bean class code embended in JSP page work without explicitly create a class file?

thank you.

regards
yan cheng
Avatar of searlas
searlas

So, you're saying if you extract out the localbean declaration and compile to localbean.class it works?
The problem is that your class="localbean" attribute assumes your localbean is not defined in a package.  However, when your JSP gets compiled it is put into a package as thought it had "package jsp_servlet.subdir.subdir.subdir;" - depending on the path to your JSP.

Avatar of yccheok

ASKER

ya, that's it. then, how do i make my JSP noe the code is embended into the JSP file?
no, you cannot!
ASKER CERTIFIED SOLUTION
Avatar of searlas
searlas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you are right searlas.
>> I suspect the implementation is app-server depenedent
I affirm it. I should have been more clearly but that's why I said no.