0

I want to write a function say count(); in one jsp page, and call it from script of another jsp page.

Can somebody suggest me how should I proceed? The count() function of the first jsp page is not defined in the script.

Nick
  • 1,417
  • 1
  • 14
  • 21
nitin7805
  • 203
  • 2
  • 13

2 Answers2

0

you can use tag.

<jsp:forward page={"relativeURL" | "<%= expression %>"} />
or
<jsp:forward page={"relativeURL" | "<%= expression %>"} >
<jsp:param name="parameterName"
          value="{parameterValue | <%= expression %>}" />+
</jsp:forward> 

Examples

<jsp:forward page="/servlet/login" />
<jsp:forward page="/servlet/login">
<jsp:param name="username" value="jsmith" />
</jsp:forward> 
Jwalin Shah
  • 2,451
  • 1
  • 17
  • 22
0

I don't think that is possible. JSPs are used to view things. If your function is written in Java, then you should make another class that implements this function. In your JSPs, you import that class and this way it will work. You shouldn't write too much Java code in a JSP.

Dragos
  • 2,911
  • 12
  • 39
  • 55