• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ven jovovich
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

if yes then remove .class from import.
 
Stefan Evans
Bartender
Posts: 1692
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stefan, it's working.
Solved.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic