Limit length of characters output in JSP string

I have a JSP site reading data in from a bean. I want it to only print the first 40 characters of the description. How would I do this? Below is the code section reading in the data

<c:forEach items="${dresses}" var="bean" >

I found a JSTL function which can do this and have that working, however in the process I found the back button isn’t working and I can’t figure out why. If anyone can spot the issue, I’m sure it’s something simple that I’m overlooking because I’ve been staring at this too long, I’d appreciate it.

JSP code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="" prefix="c"%> <%-- imports the core tags from JSTL, prefix "c"--%>
<%@taglib uri="" prefix="fn" %> <%-- imports function tags from JSTL, prefix "fn"--%>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Bridesmaid Dresses</title>
        <table frame="box">
            <tr><th>Dress Name</th><th>Short Description</th></tr>
            <c:forEach items="${dresses}" var="bean" >
                <c:set var="shortDesc" value="${fn:substring(bean.description, 0, 40)}" />
        <br />
        <form action="Controller" method="POST" >
            <input type="submit" name="button" value="Back"> <%-- Return to the servlet --%>


package homework;

import java.util.List;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Controller extends HttpServlet {

    private List<DressBean> dresses = new Vector<DressBean>(5);

public void init() throws ServletException {
        dresses.add(new DressBean("Alfred Angelo Pleated Strapless Dress",
                "Who says you can’t wear a bridesmaid dress again? This dress hugs your curves in all the right places to give a slimming look. The strapless sweetheart neckline is elegant and perfect for any bridesmaid. This tea length dress is fully lined dress, back zip, and dry clean only and is available in sizes 2 - 20W and comes in all 20 colors.",
                149.99, "aa.jpg"));
        dresses.add(new DressBean("David's Bridal Sleeveless Chiffon Dress",
                "A 'must have' for your bridal party. This dress has a high neckline and keyhole detail on the back. Made from tafeta, this dress features an elastic waist to help flatter any figure. Designed at knee length it is fully lined with a back zip. This dress is available in canary, clover, malibu, and plum and is available in sizes 0 - 30W.",
                149.0, "db.jpg"));
        dresses.add(new DressBean("Jenny Yoo Organza Strapless Dress",
                "A whimsical and charming look that your bridesmaids will love. This dress is breathtaking with the addition of pick-up points at the skirt. Made from organza, it has optional spaghetti straps to make everyone comfortable. This dress is available in all 20 colors and sizes 2 to 20W and 8JB to 16JB.",
                159.99, "jy.jpg"));
        dresses.add(new DressBean("Lela Rose Chiffon Strapless Dress with Cap Sleeves",
                "This ravishing dress features a sweetheart neckline with cap sleeves. Available in floor length or tea length, it includes an optional rhinestone flower waistband. It is available in wheat, silver mist, copper, sunset, and guava in sizes 0 to 20W and maternity sizes.",
                140.99, "lr.jpg"));
        dresses.add(new DressBean("Donna Morgan Strapless Satin Ballgown",
                "Take a step into the old world with the satin ballgown style dress. The illusion neckline and flowered waistband add a unique twist to this dress that everyone will love. Available in dark pacific, cameo, bermuda blue, and carnation and sizes sizes 0 to 30W and 8JB to 16JB.",
                188.99, "dm.jpg"));

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession();
        String target = "/viewDresses.jsp";
        int index = 0; \\
        Integer position = (Integer) session.getAttribute("position");
        if (position != null)
            index = position.intValue();
        String button = request.getParameter("button");
        if (button == null || "".equals(button)) {
        } else if ("Next".equals(button)) {
            index = index + 1;
            if (index >= dresses.size()) {
                index = 0;
        } else if ("Prev".equals(button)) {
            index = index - 1;
            if (index < 0) {
                index = dresses.size() - 1;
        } else if ("List".equals(button)) {
            target = "/dressList.jsp";
            request.setAttribute("dresses", dresses);
        } else {
        session.setAttribute("position", new Integer(index));
        request.setAttribute("dress", dresses.get(index));
        ServletContext context = this.getServletContext();
        RequestDispatcher dispatcher = context.getRequestDispatcher(target);
        dispatcher.forward(request, response);

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);

My guess is that your form action value is wrong. Did you mean “/Controller”

Also, I don’t know why you’re doing this in servlet/jsp… I strongly recommend that you use MVC framework. My fav is Spring MVC. No need to re-invent the wheel.