Prasad Saya wrote:servlet:
jsp:
SCJP 5, OCPJP 7, 8, SCJD 5, SCWCD 4, SCBCD 5, SCJWS 4, IBM OOAD 833 & 834, MongoDB Developer
Prasad Saya wrote:That is only an example. You have to provide your own application's variables (whatever they are).
Dave Tolls wrote:Well, the first thing that needs to be said is that you really shouldn't be using a static object like that in a web app.
It's not threadsafe.
Indeed, if another request came in adding a new Employee while the first request was attempting to iterate over the current List, then the first thread would throw a ConcurrentModificationException, and you'd be hard pushed to figure out why.
It's what databases are for.
Though you could make the List threadsafe using Collections.synchronizedList(), though reading that and you'd still have issues with the iterating.
Dave Tolls wrote:But you then have the thread-safety issue, and synchronising issues (especially with the JSP side as you can't do that with tags).
If you have to do it this way, then the List must be a synchronized one (as I mentioned above) and then a copy of the list should be provided to the JSP page, via the request.
Bear Bibeault wrote:Why are you redirecting to the JSP rather than forwarding?
Rohan Kesharwani wrote:
i tried still no results any other options..!?
Dave Tolls wrote:
Rohan Kesharwani wrote:
i tried still no results any other options..!?
That wasn't intended to fix this problem.
It was intended to prevent a bug-in-waiting.
Have you added logging so you can check where in the code it is going?
Can you show the current form of the servlet code, along with the logs showing the path through that code it is taking?
Also what values are being stored and passed around?
Dave Tolls wrote:I see no useful logging int here at all.
That section at the end of the doPost is simply never going to happen if there is an error.
Log data as you go, so you at least have a chance of seeing what's happening.
As for the error itself, Prasad gave an example of what the foreach tag should look like.
If there's something about the tag you don't understand then that might be the thing to check on.
Finally, you still have the thread safety issue I mentioned.
Rohan Kesharwani wrote:can you just help me in one more thing write a jsp program in which you have a list of class in servlet and you pass that list to jsp to print using forEach
Rohan Kesharwani wrote:org.apache.jasper.JasperException: /register.jsp (line: [60], column: [20]) quote symbol expected
Consider Paul's rocket mass heater. |