Hello all i was writing some classes in jsp inside of <%! %> but there is some disadvantages , i like to take this page with the classes and make from them real compiled classes so i could use them in my jsp pages the question is how ? i tried to make simple class and put it inside of the classes directory under WEB-INF
in the jsp page when i try to call the method like this : [code][ <body>
im getting error that says :
An error occurred at line: 10 in the jsp file: /test.jsp Generated servlet error: printName cannot be resolved
Originally posted by Meir Yan: i was writing some classes in jsp inside of <%! %> but there is some disadvantages
This construct is so fraught with problems and pitfalls that it's use within JSP pages has become strongly discouraged. It still exists in JSP for backward compatibility, but you should not be using it in new code.
Why would want to declare your classes in a JSP rather than compiling them as separate units and placing them in the WEB-INF/classes folder? You're just asking for trouble. [ August 12, 2006: Message edited by: Bear Bibeault ]
hello and thanks for the reply maybe i wasn't clear but this is what i want to do and its not working for me i dont want to keep the class's inside the <%! %> i do want to make units of classes but without success
Yes, WEB-INF/classes is automatically aded to the classpath.
At this point I'd suggest that you grab a copy of the servlets specification and read through it. It will answer questions like this and give you a much better understanding of the structure of web applications. [ August 13, 2006: Message edited by: Bear Bibeault ]
1. Make sure your auxiliary class is in a package and the location under classes reflects that package. 2. Import it to your JSP correctly using the package name - see the spec. Bill
Joined: Apr 27, 2006
ok got you there partlly i must say when for example i made this packege my.test.print then im my jsp page im accssing my class like this : <% my.test.print.printName.getName() %> it is working great But when i try to import the packge name and then to use the class.method it is not working im doing the import like this:
and using im my jsp code like this: <% printName.getName() %> this way it does not work , why?