hi,

I am a newbie to Apache Struts. I'd like to know what a good Struts application 
looks like.
In our JSP pages, should we try to avoid embedded java code but use tags?
For example, i have an index.jsp page for my banking application.
When a user comes to this page, it displays the login form. When a user has 
already logged 
in, it displays the user's account list. The user information is saved in the 
session as
an instance of my User class. I wrote my index.jsp as the following:



<%
User user = (User)session.getAttribute("USER");
if (user==null) {
  %>
  <html:form action="Login">
    Login Name: <html:text property="loginName" size="16"/><br/>
    Password  : <html:password property="password" size="16"/><br/>
  </html:form>
  <%
} else {
  Iterator iter = Account.getAccountList(user);
  int count = 0;
  while (iter.hasNext()) {
    count ++;
    Account account = (Account)iter.next();
    %>
    <%= account.getName() %>
    (created on <%= account.getCreatedDate() %>)<br/>
    <%
  }
  %>
  Total <%= count %> accounts found.<br/>
  <%
}
%>



Here are my questions:

1. My business object is the Account class. It provides
a static method getAccountList(User user) to get an iterator
of all the accounts of the given user. I am calling this method directly
in my index.jsp file, but it does not seem to be a good struts programming
style. So what is the preferred way for doing this?

2. I used embedded java code for checking whether a user has logged in.
Should i use tags in the bean taglib or logic taglib to get an object from
the session and check it?

Thanks for any reply.

heavy ZHENG



ZHENG Zhong


---------------------------------
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!

Reply via email to