Editing Strings in Struts

B

Bojan

Hi,

I pass a list of type File to the servelet. The JSP page has a loop
that goes through the list, and gets a File. It creates an href for
that file and i want the name not to include the extension of the
file.

Here is the code:

<logic:iterate name="files" id="file">
<bean:define id="fileName" name="file" property="name" />
<a href="<bean:write name="file" />"><bean:write name="fileName" </a>
.....

Is there anyway i can do substring (0, size-3) or somethign along
those lines to get the file name without the extension?

Thank you for your help
 
L

Lew

Arne said:
It may be nicer to return a list of a custom type
with the properties you need.

That would have the benefit of amenability to a more model-view-controller
(MVC) style whereby one does not embed scriptlet in a JSP.

Of course, MVC is a guideline, not a straitjacket. Ne'ertheless, there's a
power in using JSP merely to display a custom list rather than to manipulate
it. For one thing, it simplifies maintenance should, say, your list grow to
include ".odt" files as well as ".doc". Or later still, ".txt". Oops, time
to add ".lst". Hmm, what about "How to write a document.doc"? Do you really
want the result to be "How to write a ument"?
 
L

Lew

Hmm, what about "How to write a document.doc"?
Do you really want the result to be "How to write a ument"?

I meant that example to be

Hmm, what about "How to write a .document.doc"?
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top