Using class method in JSP

Is it possible to use method from ordinary .class file in jsp file?If it is, please explain.
[106 byte] By [avdo77a] at [2007-11-27 5:31:39]
# 1

> Is it possible to use method from ordinary .class

> file in jsp file?

>

Yes, but in general it's a bad idea to embed Java code in your JSP.

> If it is, please explain.

Get a JSP book, or google for a JSP tutorial. Your question is rather vague, and there's no point in somebody here repeating the whole thing.

jverda at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 2
Well maybe it is vague but I need it now and I do not have a book. I do not have time neither to search the web.Hopefully, somebody will be kind enough to give me practical example.
avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 3

> Well maybe it is vague but I need it now and I do not

> have a book. I do not have time neither to search the

> web.

>

Then you're being somewhat unrealistic. You're asking people to volunteer their time to read your mind and distill for you what you'd learn yourself if you took the time to learn it properly or at least ask a better question.

I'd wish you good luck, but I wouldn't mean it, so I won't.

Bye.

jverda at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 4
I am doing something like:<% student.displayStudents(); %>but it can't recognize variable.
avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 5
Is this clear enough?
avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 6

> I am doing something like:

>

> <% student.displayStudents(); %>

>

> but it can't recognize variable.

Again, not a whole lot of information...

The only variable there is student, so clearly student is not defined in that context. That's all I can tell you based on what you've provided.

jverda at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 7
<% Student student = new Student(); %> It doesn't work with this neither.
avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 8
> <% Student student = new Student(); %> > > It doesn't work with this neither.*sigh*In what way did it not work?
jverda at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 9

C:\tomcat\work\Catalina\localhost\_\org\apache\jsp\jsp\display_jsp.java:95: cannot find symbol

symbol : class BudgetDVDDBBusinessLogic

location: class org.apache.jsp.jsp.display_jsp

Student student = new Student();

avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 10

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)

org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)

org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 11
Is that better?
avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 12
You need to have the .class files or .jar files in the right place. Classpath is generally not used by JSP containers. I assume you're using tomcat, or something like it. Check its docs and examples. Generally its something like webapps/myapp/lib/myjar.jar or something.
jverda at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 13
I placed files into right places.
avdo77a at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 14
> I placed files into right places.Oh great. So everything's working now?Well that's fantastic. Thanks for visiting us and you have a great day.
cotton.ma at 2007-7-12 14:57:03 > top of Java-index,Java Essentials,Java Programming...
# 15

> I placed files into right places.

So, you did everything correctly but it's still not working?

Then I guess tomcat is borked. Or maybe your OS. Or your CPU. I suggest you write strongly worded letters of protest to the Apache folks, Bill Gates, and whoever is in charge of Intel.

jverda at 2007-7-21 21:30:35 > top of Java-index,Java Essentials,Java Programming...
# 16
No it's to early to say good bye my friend. I still wait the answer from experts.The question is can I use it with .class and how can i do it?
avdo77a at 2007-7-21 21:30:35 > top of Java-index,Java Essentials,Java Programming...
# 17

> No it's to early to say good bye my friend.

Not for me it's not.*

> I still wait the answer from experts.

Oh, well, you got answers from me instead.

> The question is can I use it with .class

Already answered: Yes.

> and how can

> i do it?

Already answered: Read the appropriate books, docs, and examples.

*Goodbye.

jverda at 2007-7-21 21:30:35 > top of Java-index,Java Essentials,Java Programming...
# 18
That's not kind of answer I am looking for. I'll wait for the expert anyway.You can go and chill out.
avdo77a at 2007-7-21 21:30:35 > top of Java-index,Java Essentials,Java Programming...
# 19

> That's not kind of answer I am looking for. I'll wait

> for the expert anyway.

If you were really going to do that you would have posted in the JSP forum. But it's not surprising that you didn't do that.

Did you import your Student class into this lousy piece of **** you are trying to write?

DrClapa at 2007-7-21 21:30:35 > top of Java-index,Java Essentials,Java Programming...