3

I have the following code in my servlet class:

request.setAttribute("myValueName", myValue); //Note: myValue is a TreeMap

I want to access this attribute via jQuery. Does anyone know how to do this?

var myNewVariable = ???;

Note that this attribute is NOT in the URL of the page.

Snowy Coder Girl
  • 5,408
  • 10
  • 41
  • 72

1 Answers1

-2

Servlet code

response.setContentType("text/html");
request.setAttribute("myValueName", "myValue");
request.getRequestDispatcher("URL for redirecting page").forward(request, response);

Example URL ="/WEB-INF/Project/Update.jsp"

In jQquery

var myNewVariable = "${myValueName}";
alert(myNewVariable);
Miran Senanayaka
  • 154
  • 1
  • 13
HNB
  • 5
  • 1