I am trying to pass session object from sessionConstant.java to my COMP.jsp file....
sessionConstants.java
public class SessionConstants {
public static final String COMP_TYPE_GRID_JSON = "companyTypeGridModelObj";
}
and in jsp file i have a *.js script.......
<script type="text/javascript" charset="utf-8">
var aa = "${cons.COMP_TYPE_GRID_JSON}";
var bb = "${sessionScope.companyTypeGridModelObj}";
var jsonModal = <myComp:JSON object = "${bb}" />
</script>
Q1. how do i pass value in var aa instead of 'companyTypeGridModelObj' in sessionScope Object defined in var bb ...
Q2. how do i pass var bb in my jstl
please help
for code in java where this attribute is being passed
NgGridModelConvertor ngGridModelConvertor = new NgGridModelConvertor();
NgGridModel ngGridModel = ngGridModelConvertor.getNgModelData1(columnModeList, dataMapList, rtlOrientation);
getSession().put(SessionConstants.COMP_TYPE_GRID_JSON, ngGridModel);
You can refer to this thread which may answer your problem.
First you need to insert you value inside the session scope. Then you can access your data from your JSP file. As you are using tag, I suppose you're not using separate js file. If you do use separate file, then you'll have to use another way to pass your data, as Ajax call or hidden input.
Servlet :
JSP :
OR to have named value :
for your situation :
EDIT : Use of TagLib
Here you have the official documentation on TagLib. You should read this, it will probably give you more information.
For your problem : In your tag file you declare a tag with attributes. That way, when you call this tag you can pass your ${bb} value to the tag.
In my tag file (reference to my personal code, maybe it can be improved)
In my main JSP