开发者

JSP calling a function from another jsp file

开发者 https://www.devze.com 2023-01-22 01:03 出处:网络
Hi i have开发者_StackOverflow中文版 a JSP file , while trying to add code i got the 64k limit error.

Hi i have开发者_StackOverflow中文版 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 ?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消