![]() |
| ||
| a simple jsp question hey guys, I'm realtively new to jsp, and I want to create java objects and use them later in the jsp code. Here's what I do: <%! However, I get errors of the sort: Unable to compile class for JSP: |
| ||
| Re: a simple jsp question <%! %> tags are used for declarations. I recommend you don't use this for anything other than declaring your variables, and this is probably the cause of your issues. Just use normal scriptlets <% %> for your actual statements. Good luck |
| ||
| Re: a simple jsp question hey, you are right abut the declaration tags. However the problem seems to be different - I cannot mix jsp and jstl tags (particularly, I cannot use the myBool variable in the c:out tag) Therefore I still need your help. I have to go through the elements of a collection (preferably using jstl <c:forEach>) but for each element I want to check whether I have already passed through another one with the same attribute_1. If yes, then I print it's attribute_2, if not - I print both attributes. So, obviously I need to keep track whether another element with the same attribute_1 has been already checked in the "forEach" loop. Hence, I think I should use a container like ArrayList or something similar to check whether myArrayList.contains(myAttribute_1). Is there a way to keep track of these attributes in jstl, or I should use pure jsp ?!? ... or can I create the ArrayList in jsp and then somehow use it within the jstl <c:forEach> tag? maybe my problem description is a littel confusing - sorry - just ask if you don't understand something. :) Pesho |
| ||
| Re: a simple jsp question Well, don't mix them. Eliminate the scriptlets altogether. You should be doing this stuff in Beans, and the like. |
| ||
| Re: a simple jsp question ok :) but what if in the JSP tags I want to use info passed by the servlet? For instance, in my servlet I have the following: Animal myAnimal = new Animal(); Now in the jstl tags of myJSP.jsp I can use the following: <c:forEach items='${myAnimal.body.legs}' var="leg">
BUT I cannot use the following: <% for(int i=0; i<myAnimal.getBody().getLegs().length; i++) { %>
... it complains that myAnimal cannot be resolvedCould you please explain why I cannot use "myAnimal" in the plain JSP tags??? Thans a lot ! ! ! |
| All times are GMT -4. The time now is 5:23 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC