java - Transferring collection object from one jsp to another -
I get data from the database and store it in some archive in a collection (say one.jsp). I should have this collection object available in another jsp (two .jsp). There can be large data in it, so, I have used the Java Bean in the following manner.
Public class Beacon series SerialJobs {Private Hashmap & lt; String, list & lt; String & gt; & Gt; MyMap; Private Ent ID; Public int getId () {return ID; } Public Zero setId (int id) {this.id = id; } Public Hashmap & lt; String, list & lt; String & gt; & Gt; GetMyMap () {return myMap; } Public Zero SetData (Hashmap string> gt; & gt; my map) {this.myMap = myMap; }} I am setting the beans in One.jsp in the following manner. & lt; Jsp: useBean id = "Data object" class = "com.mapac.bine class" scope = "session" /> & Lt; Jsp: setProperty name = "dataObject" property = "mam map" /> & Lt;% dataObject.setData (myMapObj); & Gt%; But I get the following error:
No 'method' to type 'java.util.hashMap' type 'dataMap' A type of beam 'com.mypack.BeanClass' Somewhere I found that we can not set up for other things, as long as this string is not there. Anyway, can I work to get it working for the collection object too? So I do not have to return a lot of things which I have done. If not, then no one can suggest how to move the collection object from one JSP to another. Example with the snippet is appreciated.
Or is it that some additional configurations are missing for me to work beans?
Note: I may have used redirect () method, but here it is done by clicking one.jsp to Two.jsp by clicking on the navigation hyperlink (href) Edit: Thank you for Alferma. After my solution was set up, it was worked out, but two. I am facing problems in JSP. I try to display some part of the map as below. But it shows everything that is present in the map as it shows when we use it. Println (myMap); And after displaying the contents of the entire map, the table displays at the very end of the page.
Two. Jsp: & lt; Jsp: p = "header.jsp" /> & Lt; Jsp: useBean id = "dataObject" class = "com.mypack.BeanClass" scope = "session" /> & Lt; Jsp: getProperty name = "dataObject" property = "mimp" /> & Lt;%! HashMap & LT; String, from the list & lt; String & gt; & Gt; GottenMap = Null; & Gt%; & Lt;% gottenMap = dataObject.getMyMap (); & Gt%; & Lt; Table & gt; & Lt; Tbody & gt; & Lt;% string selected PART = request.getParameter ("section"); & Lt; String & gt; List = gottenMap.get (selected part); For (int i = 0; i & Lt; TR & gt; & Lt; Td colspan = '2' & gt; & Lt; Strong & gt; & Lt;% = list.get (i)% & gt; & Lt; / Strong> & Lt; / TD & gt; & Lt; / TR & gt; & Lt;%}% & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; Why do I do this without fully coding for printing?
Change this:
& lt; Jsp: useBean id = "dataObject" class = "com.mypack.BeanClass" scope = "session" /> & Lt; Jsp: setProperty name = "dataObject" property = "mam map" /> & Lt;% dataObject.setData (myMapObj); & Gt%; To do this:
& lt; Jsp: useBean id = "dataObject" class = "com.mypack.BeanClass" scope = "session" /> & Lt; Jsp: setProperty name = "dataObject" property = "data" value = "$ {myMapObj}" /> Your setter is called "SetData (...)", "setMyMap (...)" JSP is going to see property = "data" and calling set data (...).
So that you can heal you, but you have not shown us where you are setting your map obz. We have to admit that you are setting the right way upwards and made it available through a page for the tag. Context.setAttribute ("myMapObj", myMapObj); Call.
Side note: I recommend that MyMap (...) conform to recipient getMyMap (...) to rename the setData (..) method. If you do this, then you have to change the property "=" ... "MimePap" back as you did.
Comments
Post a Comment