Creating an inline function in a jsp?

Posted by user246114 on Stack Overflow See other posts from Stack Overflow or by user246114
Published on 2010-04-24T21:31:06Z Indexed on 2010/04/24 21:33 UTC
Read the original article Hit count: 606

Filed under:
|

Hi,

I'm coming from (some limited) PHP experience, in which you can just declare functions in-line. I'm trying to the same thing with a JSP but not working. Trying something like:

<%!
  private void generateSomething() {
      %> <p> Hello there! </p> <%
  }
%>

<%
  generateSomething();
%>

is something like that possible? Basically I have a jsp that can generate a 3 different pages, and I wanted to put these each in a separate method.

I have seen a few posts saying this is not a good idea, and to separate the presentation stuff, which is fine, I just want to see this in action, if possible, now I'm just curious,

Thanks

© Stack Overflow or respective owner

Related posts about servlet

Related posts about jsp