1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

JSP Bean in javascript lead to blank page

Discussion in 'JSP' started by kanak09, Feb 14, 2012.

  1. kanak09

    kanak09 New Member

    Feb 14, 2012
    Likes Received:
    Trophy Points:
    Hello everyone !
    I'm developping a JSF application. My pages are JSP extension and i have some javascript scripts inside.
    My situation is simple but can't solve it. I have to fill in javascript tabs thanks to values provided by my beans.

    Here is my code : ( i replaced my true classes ^^)
    <%@page language="java" import="com.test.Toto"%>
    <jsp:useBean id="totoManager" class="com.test.TotoManager"></jsp:useBean>
     <script type="text/javascript">
      var categories;
      var data;
      var count;
    <% for (com.test Toto: totoManager.getJokes()) { %>
                      categories.push(<%= toto.getCategory() %>);
                         title: <%= toto.getTitle() %>,
                         joke:<%= toto.getText() %>       
      <% } %>
    Here is the result i'd like to obtain after the loop :
                var categories = ['Poo', 'Funny', 'Toto's Mother'],       var data = [{              title: 'blabla',             joke: 'wonderful joke',          }, {             title: 'foo',             joke: 'so funny',          }]
    If i remove the script the page loads correctly, but with the script, it remains blank, with no source code ...
    So i might have a problem calling my bean !

    Thanks for helping

Share This Page