C
CADVector
Unregistered / Unconfirmed
GUEST, unregistred user!
这是JSP文件
<%@ page import="Beans.NameBean"
%>
<jsp:useBean id="pageBean"
class="Beans.NameBean"
scope="page"
>
<jsp:setProperty name="pageBean"
property="*"
/>
</jsp:useBean>
<jsp:useBean id="sessionBean"
class="Beans.NameBean"
scope="session"
>
<jsp:setProperty name="sessionBean"
property="*"
/>
</jsp:useBean>
<%/* dfgfd */%>
<html>
<head><title> The UseBean JSP</Title></head>
<body>
<H3>Welcome to The UseBean Jsp</H3>
<P>May we have your name>
<P><b>Page bean:</B>
<% if (pageBean.getNewName().equals(""){%>
Ido
n't know you.
<%} else
{%>
hello <%= pageBean.getNewName()%>!
<%}%>
<P><b>Session bean:</B>
<% if (sessionBean.getNewName().equals(""){%>
Ido
n't know you either.
<%} else
{
if ((request.getParameter("newname"==null)||
(request.getParameter("newname".equals("")){%>
aha,i remember you.
<% }%>
you are <%=sessionBean.getNewName()%>.
<% }%>
<Form action = "usebean.jsp"
Method= get>
<input type= Text name= newname size= 20 >
<input type= submit value="Submit name"
>
</form>
</body>
</html>
这是JAVABEAN
package Beans;
public class NameBean{
String newname="sss";
public void NameBean(){}
public String getNewName(){
return newname;
}
public void setNewName(String newname){
this.newname=newname;
}
}
问题一:
我运行了JSP后出现页面如下:
Welcome to The UseBean Jsp
May we have your name>
Page bean: hello sss!
Session bean: aha,i remember you. you are sss.
这行是一个文本框和一个按钮
然后我在文本框中输入1111内容后,再按按钮后,应该输出
Welcome to The UseBean Jsp
May we have your name>
Page bean: hello 1111!
Session bean: you are sss.
但是好象不对啊,不知道为什么?请指点
<%@ page import="Beans.NameBean"
%>
<jsp:useBean id="pageBean"
class="Beans.NameBean"
scope="page"
>
<jsp:setProperty name="pageBean"
property="*"
/>
</jsp:useBean>
<jsp:useBean id="sessionBean"
class="Beans.NameBean"
scope="session"
>
<jsp:setProperty name="sessionBean"
property="*"
/>
</jsp:useBean>
<%/* dfgfd */%>
<html>
<head><title> The UseBean JSP</Title></head>
<body>
<H3>Welcome to The UseBean Jsp</H3>
<P>May we have your name>
<P><b>Page bean:</B>
<% if (pageBean.getNewName().equals(""){%>
Ido
n't know you.
<%} else
{%>
hello <%= pageBean.getNewName()%>!
<%}%>
<P><b>Session bean:</B>
<% if (sessionBean.getNewName().equals(""){%>
Ido
n't know you either.
<%} else
{
if ((request.getParameter("newname"==null)||
(request.getParameter("newname".equals("")){%>
aha,i remember you.
<% }%>
you are <%=sessionBean.getNewName()%>.
<% }%>
<Form action = "usebean.jsp"
Method= get>
<input type= Text name= newname size= 20 >
<input type= submit value="Submit name"
>
</form>
</body>
</html>
这是JAVABEAN
package Beans;
public class NameBean{
String newname="sss";
public void NameBean(){}
public String getNewName(){
return newname;
}
public void setNewName(String newname){
this.newname=newname;
}
}
问题一:
我运行了JSP后出现页面如下:
Welcome to The UseBean Jsp
May we have your name>
Page bean: hello sss!
Session bean: aha,i remember you. you are sss.
这行是一个文本框和一个按钮
然后我在文本框中输入1111内容后,再按按钮后,应该输出
Welcome to The UseBean Jsp
May we have your name>
Page bean: hello 1111!
Session bean: you are sss.
但是好象不对啊,不知道为什么?请指点