Challenge: Include JSON output for JSP
(too old to reply)
Kevin Zhang
2014-09-21 16:11:55 UTC
Hi All,

Suppose I have implemented two web service /ws/author/${authorId} (return a User object) and /ws/books-of-books/${authorId} (return a list of books). I also have a jsp file ..../author.jsp?authorId=xxxxx.

In my jsp file, I would like to do sth like

var author = <% request.getRequestDispatcher("/ws/author/" + request.getParameter("authorId")).include(request, response);%>
var books = <% request.getRequestDispatcher("/ws/books-of-author/" + request.getParameter("authorId")).include(request, response);%>

// some jquery scripts which use author and books variables.

In my test code, if I run curl "", I got the json output correctly.

my test index.jsp is

docs = <% request.getRequestDispatcher("/ws/document").include(request, response);%>

The output of my index.jsp is below. The json is not printed as expected.

<script type="text/javascript">
docs =

The reason why I include web service in JSP is because I would like to get multiple jsons and from web service.

Thanks a lot,