0

I'm using Spring MVC to pass a ArrayList object from my Controller to JSP and I want to iterate it over there using JSTL (forEach), but it is always crashing Java server after 10~20 seconds loading the page. It's not throwing any exception.

Trying to use "c:out" to print the String representing the array works fine. Same to not empty validation. It always crashes when program reaches the forEach.

SIMPLIFIED EXAMPLE BELOW

Controller method

@RequestMapping(value = "/main", method = {RequestMethod.POST}, params = "create")
public ModelAndView createBranch (Branch branch) throws FxtrmServiceException, JsonGenerationException, JsonMappingException, IOException{

    ModelAndView branchMV = new ModelAndView("branch");


    ArrayList<String> array1 = new ArrayList<String>();
    array1.add("test1");
    array1.add("test2");

    branchMV.addObject("alertMap1", array1);

    populateAutoCompletes(branchMV);

    return branchMV;    
}

JSP:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"  %>
(...)
    <c:if test="${not empty alertMap1}">
        <c:forEach items="${alertMap1}" var="entry1">
                    <c:out value="${entry1}"/><br>                            
        </c:forEach>
    </c:if> 
Cech
  • 1
  • 1
  • 1
    What do you mean by "crash"? Does the server become unresponsive? – matts Mar 19 '13 at 18:53
  • In your Spring controller, log the size of the map/array. – parsifal Mar 19 '13 at 18:55
  • @matts The server stops responding and I need to restart it. – Cech Mar 19 '13 at 19:05
  • @parsifal Can you clarify how to do that? Thanks. – Cech Mar 19 '13 at 19:07
  • Does `populateAutoCompletes` do anything related to the `alertMap1` object? – matts Mar 19 '13 at 19:31
  • @matts nothing related... :( – Cech Mar 19 '13 at 19:35
  • Have you tried commenting out `populateAutoCompletes(branchMV)`? – clav Mar 19 '13 at 20:15
  • @clav yes, but the problem remains – Cech Mar 19 '13 at 20:32
  • Have you tried replacing the `` tag with just `${entry1}` – clav Mar 19 '13 at 21:38
  • When the "server stops responding," is that to everything? Can you connect to the server from another browser? – parsifal Mar 20 '13 at 13:04
  • Also, what does the thread dump look like? You don't say what platform you're on, and the methods to get the dump will differ depending on Windows/Linux/other. The Websphere docs should help you if you don't already know how to do this. – parsifal Mar 20 '13 at 13:06
  • @parsifal yes, stops responding and it crashes. I can't connect from any client. The only way is to restart it. – Cech Mar 21 '13 at 17:52
  • @parsifal I'm running on Windows 7, local server for development. I'm not sure what is the tread dump. Can you help me on it? Tks. – Cech Mar 21 '13 at 17:53
  • Here is some information about generating a thread dump: http://stackoverflow.com/questions/2124672/java-stack-dump-on-windows – parsifal Mar 21 '13 at 18:35
  • However, if that's truly the code that you're executing, there is no way that it could completely lock up your server. It's possible that you have a corrupted JVM or Websphere install, and is probably worth reinstalling. If it's not the actual code, you need to post the actual code. – parsifal Mar 21 '13 at 18:36
  • I just reinstalled RAD and it worked. Thank you all. – Cech May 14 '13 at 19:47

0 Answers0