JSP BEAN RETRIEVAL

V

Vittorix

Again, I try to explain in a simpler way:

in a JSP page:

<%
String bookBeanBeg;
bookBeanBeg = "bookBeanBeg1";
%>

<jsp:useBean id="<%=bookBeanBeg%>"
type="p4Solution.BookBean" scope="session" />
<jsp:getProperty name="<%=bookBeanBeg%>"
property="shortDescription"/>

it doesn't work.

please help to make it work. I'm going crazy with it!
 
V

Vittorix

Vittorix said:
in a JSP page:

<%
String bookBeanBeg;
bookBeanBeg = "bookBeanBeg1";
%>

<jsp:useBean id="<%=bookBeanBeg%>"
type="p4Solution.BookBean" scope="session" />
<jsp:getProperty name="<%=bookBeanBeg%>"
property="shortDescription"/>

it doesn't work.

this could be helpful for somebody in the future, then I post it here:

because I couldn't find a solution, I'm using a scriplet inside the JSP that
does the job:

int numBooks = Integer.parseInt(request.getParameter("numBook"));
for (int i=1; i<=numBooks; i++)
{
String bookBeanS = "bookBeanBeg" + i + "";
p4Solution.BookBean bookBean = null;
bookBean = (p4Solution.BookBean) session.getAttribute(bookBeanS);
out.write(bookBean.getSeq_no());
}
 
A

Arne Vajhøj

Vittorix said:
this could be helpful for somebody in the future, then I post it here:

because I couldn't find a solution, I'm using a scriplet inside the JSP that
does the job:

int numBooks = Integer.parseInt(request.getParameter("numBook"));
for (int i=1; i<=numBooks; i++)
{
String bookBeanS = "bookBeanBeg" + i + "";
p4Solution.BookBean bookBean = null;
bookBean = (p4Solution.BookBean) session.getAttribute(bookBeanS);
out.write(bookBean.getSeq_no());
}

JSP pages with scriptlets with out.print/write should not
be able to pass code review.

Arne
 
L

Lew

Vittorix said:
what do you mean? it works great

He means that the presence of scriptlet in a JSP is a "bad" mark in a code
review. It presents maintenance difficulties, and obviates the natural
separation of view artifacts from logic artifacts. It also represents that
you left a bug unfixed, in that the <c:forEach> idiom should work, so from an
organizational standpoint that remains an open issue.

I have known a few people who had Marty Hall as a teacher. He took off ten
points from an assignment submission for each line of scriptlet in a JSP.
<http://www.apl.jhu.edu/~hall/>
 
V

Vittorix

Lew said:
He means that the presence of scriptlet in a JSP is a "bad" mark in a
code review. It presents maintenance difficulties, and obviates the
natural separation of view artifacts from logic artifacts.

right. but I didn't find a solution, what I gotta do?
It also
represents that you left a bug unfixed, in that the <c:forEach> idiom
should work, so from an organizational standpoint that remains an
open issue.

I agree. what do you suggest?
I have known a few people who had Marty Hall as a teacher. He took
off ten points from an assignment submission for each line of
scriptlet in a JSP. http://www.apl.jhu.edu/~hall/

too bad that he wants us to buy the second volume of his book to tell us how
a <c:forEach>. works...
 
V

Vittorix

It is my observation that Professor Hall is mighty good at promoting
himself and his products.

and I reinforced it :)
however, his book is decent and the first volume is online for free.
You can get an overview of the JSTL tags for free in the Sun Java EE
tutorial. <c:forEach> is covered in:
<http://java.sun.com/javaee/5/docs/tutorial/doc/bnakh.html#bnakm>

thanks, I don't know why I tried the approach and nothing is shown in the
page.
I posted the code on another thread, if you like to see it.
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top