Rqgg Page 1/2

tieplantlimabeansSoftware and s/w Development

Oct 28, 2013 (3 years and 10 months ago)

399 views

JSP request is not pass to another jsp page when using jquery load method
Asked by
Brooksky
on 2013-03-26T03:59:30-04:00
I encountered a problem when using jquery's load() method in JSP page. In the first page, I am
trying to set attribute list1 into request and use load() to load contents of page 2 into page 1's
"#content".


list1 = new ArrayList
(); request.setAttribute("list1", list1); %>
$("#content").load("page2.jsp");



In second page, list1 is being retrieved from request and do some processing before being output by
out.println()


list2 = (ArrayList
) request.getAttribute("list1"); // process something here if (list2==null){
out.println("list2 is null"); } else { // out.println() contents of list2 } %>
Then here is where the
problem lies.
request.getAttribute("list1")
in page 2 returns null pointer, and after some research I
found that request is not being sent to page 2 so I cannot retrieve "list1" from request.

I cannot use
request.getRequestDispatcher("page2.jsp").forward(request, response)
in page 1 as
it will redirect me to page2.jsp, that is not what I intended to do.

Is there any work around that I can pass request to page 2 so that I can retrieve the data? Thanks.

Best Answer
Answer by
Jai
on 2013-03-26T04:02:05-04:00
wrap it in
doc ready
:


$(function(){ $("#content").load("page2.jsp"); });
Archives
Technology
Programmers
Mar 26th, 2013
Week 13, 2013
March, 2013
Related
Dynamically adding links in a webpage by retreiving values from database
jquery - drill down into iframe
simplexml_load_string fails to load xml from a url
How to show form input fields based on select value?
How to add JSP variable in jQuery?
Dont submit form after pressing a button
Why does jQuery .data() method only return the first word in a String?
jquery trigger action on option add
AutoComplete using jquery pass value to hidden field
How to call Action using Ajax in Strut2
View Online
Rqgg
Page 1/2
JSP request is not pass to another jsp page when using jquery load method
http://www.rqgg.net/topic/inimt-jsp-request-is-not-pass-to-another-jsp-page-when-using-jquery-load-
method.html
Rqgg
Page 2/2