Hi there, If anyone can help push me in the right direction it would be most appreciated. I need to do a JSP page but I need to reuse some 'Functions' (ASP like functions, pass some variables into it, get desired output back!). How do I implement these functions into the ASP page, I keep getting errors like : Error: No match was found for method "createDateBoxes(java.lang.String, int, int, int, int, int This happens when I try and put my public String createDateBoxes(String.... ..... } directly into the JSP page. Should I be making it a Java class? Why can't I include it directly into the JSP page? Why is it not WORKING (sorry, getting a wee bit frustrated here.....) Any help would be appreciated. Cheers David Eilloc
One of the best ways to figure out how JSP works is to look at the java file that is generated. What you would probably see in your instance is that the method you are declaring is inlined within another method. Oopsy! If you placed the method declaration within the JSP declaration delimiters <%! ... %>, the JSP container knows to make that a declaration within the servlet that is generated. I'd argue however that the best place for such methods would be in a bean that helps to keep Java OUT of the JSP pages, and that can be resued across pages. hth, bear
I'll confess I've written a few function definitions in JSPs, but now I've seen the light Actually, while Microsoft used the fact that their .NET demos had fewer source files than the J2EE equivalents as a bragging point, at the enterprise level it's really much cleaner to keep the code in a code file and the markup in a markup file - something that ASP isn't noted for. While it's slightly more work that way, it's easier to maintain the page markups if they aren't cluttered with code. Relatively few HTML editors do well with big chunks of non-markup code splattered all over the page. Also, if you ARE working at an enterprise scale, the actual markup may be handled by an artistic-type person who's not that familiar with programming, so it's safer to put the code somewhere it's not as likely to get damaged. It's easy to call code from a JSP - the compiled classes go in the WEB-INF/classes directory (or WEB-INF/lib if they are in a JAR file). If you haven't tried Ant (http://jakarta.apache.org/ant), I recommend it - it's simple to use and can handle the drudge work involved in building and deploying web apps. And, of course, don't forget JSP tags! One of the neat things about JSP is that you can define your own custom "HTML" tags. That way page artists can plop down active logic requests in HTML format and never get into Java code at all.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Jul 19, 2001
Cheers guys! That has made things a little bit clearer. Just a wee bit of bg info, I am an ASP developer that needs to do just this one thing in JSP/Java. I just didn't really know where to start, and you guys have pointed me in the right direction. Virtual pints on me! David Eilloc