tags:

views:

20

answers:

2

Hi i have a JSP file , while trying to add code i got the 64k limit error. so i decided to add the code to another jsp file and include it inside the first one.

so i have

first.jsp

.....
<jsp:include page="second.jsp"/>
....
<%= foo(); %>

second.jsp ....

<%!
public String foo()
{
 return "test";
}
>%

i try using this and i get this error message: "The method foo is undefined for the type first_jsp"

any idea what is the problem and how i can solve this ?

A: 

Stop using scriptlets. Use JSTL tags to access your data and write your Java code in servlets/regular java classes.

Bal
+1  A: 

This is the wrong way to do it.

First, if you want some method, create a Java class, and import it using <%@ page import="your.package.YourClass*" %>

Second, don't use scriptlets in the JSP page at all. Use JSTL. Possibly JSTL functions. See here

Bozho
ok , so you are saying i should only use this <%= %> and avoid using java inside with those <% %>
you should not use these scriptlets at all
Bozho
so if i understand correct i should put inside a jsp file only html and <%= x %> and do all my logic in a java class ?
http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files see here
Bozho
thank you very much!