JSP/Bean/Custom Tag Design Question

R

Robert Jones

I'm working on my first JSP application and I've run into a design
problem that I can't seem to find a good solution to. I need to access
a dynamic list of files and display some information about each of them
in a table in a JSP page.

Here are the details:

I have a directory. I get a list of the files in that directory that
match a certain pattern. I open each file in succession and read a
couple of lines from them. I display the contents of these lines on a
web page.

The problem is that the number of files changes. That's why I'm using
the custom tag. I use a forEach loop in the JSP tag to process each
file. I pass the value of the iteration variable to the custom tag so
it knows which file to access.

I also need to create a URL that includes the name of the file I am
accessing. I don't see how to get the value of the filename into the
value attribute of c:param.

<c:url var="reviewURL" value="./viewloc.jsp">
<c:param name="filename" value="" />
</c:url>
<a href="<c:eek:ut value="${reviewURL}" escapeXml="false" />">Review</a>

Normally, the filename is available through a getter method for the
bean, but I don't see how I can use this inside the c:param tag, being
that the getter method would need an index.

Any help or recommendation is appreciated greatly. I can provide code,
but I didn't want to clutter up my post if it isn't necessary.

Robert Jones
 
E

Erwin Moller

Robert Jones wrote:

I'm working on my first JSP application and I've run into a design
problem that I can't seem to find a good solution to. I need to access
a dynamic list of files and display some information about each of them
in a table in a JSP page.

Here are the details:

I have a directory. I get a list of the files in that directory that
match a certain pattern. I open each file in succession and read a
couple of lines from them. I display the contents of these lines on a
web page.

The problem is that the number of files changes. That's why I'm using
the custom tag. I use a forEach loop in the JSP tag to process each
file. I pass the value of the iteration variable to the custom tag so
it knows which file to access.

I also need to create a URL that includes the name of the file I am
accessing. I don't see how to get the value of the filename into the
value attribute of c:param.

<c:url var="reviewURL" value="./viewloc.jsp">
<c:param name="filename" value="" />
</c:url>
<a href="<c:eek:ut value="${reviewURL}" escapeXml="false" />">Review</a>

Normally, the filename is available through a getter method for the
bean, but I don't see how I can use this inside the c:param tag, being
that the getter method would need an index.


Hi Robert,

If you are coding your own custumtaglib already, why not iterate through
the files from their in the first place, instead of creating a Loop
outside your own taglib?
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top