aspose file tools
The moose likes JSP and the fly likes How to access a simple method of a class from jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to access a simple method of a class from jsp?" Watch "How to access a simple method of a class from jsp?" New topic
Author

How to access a simple method of a class from jsp?

ven jovovich
Ranch Hand

Joined: Sep 06, 2012
Posts: 33
Hi all,
I am trying to access a java class from my JSP code but I just can't import the package. Following is my directory structure:


a.jsp is as follows:



MyUtil.java is as follows:



The following is the error on page http://localhost:8080/test_jsp/a.jsp:


I simply cant import my class / package. Please tell me where I am going wrong.

Regards,
Ven Jovovich.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575


that's perfect for me.
perhaps you tried with below one ?

if yes then remove .class from import.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1268
    
    6
ROOT does not mean what you think it means.
ROOT is the "default" web application. The one that is accessed if the url doesn't match any existing contexts.

Your WEB-INF directory must always be in the top level of your web application to have any effect.
Because you have yours in webapps/ROOT/test_jsp/WEB-INF, it doesn't recognise it as valid. As a result it doesn't recognise the classes directory, and can't find your java class.

Suggested fix:
Move your test_jsp folder up a level from ROOT to webapps. ie: webapps/test_jsp
Restart your server.

Things should start working as you expect at that point.

cheers,
Stefan
ven jovovich
Ranch Hand

Joined: Sep 06, 2012
Posts: 33
Thanks Stefan, it's working.
Solved.
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: How to access a simple method of a class from jsp?