score:0

Accepted answer

this answer to this question has nothing to do with my setup or import statements. the correct answer is that eclipse doesn't make it clear what code it "sees" (or that its compiling) when it runs the project. on my jsp page, it showed it as recognizing the call to my java code. however, when i ran the page, it was still compiling the older version of my java code, that didn't have my latest changes. i've found the best way to guarantee that the newest version of my referenced java code is compiled when i run my .jsp program (that calls the java) is to go to "project->build all" then go to "servers", right click "publish". if publish isnt an option, and it thinks its already synchronized, then you may have to change the .jsp page, save it, then "publish" will become active again.

score:1

you need to have the java ee version of eclipse installed, and create a java web application, which will allow you to set up a web.xml.

eclipse jee which i have installed to set up web projects is: http://eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplerr

your web.xml will definte your web servlets, which can be jsp's or java classes that extend a servlet implementation.

this has less to do with your ide (eclipse) than it does with java web applications.

you should read this documentation for starters from oracle about web apps, and go from there on setting up an ide:

http://docs.oracle.com/javaee/1.4/tutorial/doc/webapp.html

edit based on user feedback

import should be to class level:

<%@ page import="fully.qualified.someclass" %> 

then from your jsp code:

<%  
  someclass someclass = new someclass();  
  someclass.helloworld();  
%>  

edit 2 based on feedback

try this link to do using page include: http://www.coderanch.com/t/286168/jsp/java/calling-java-classes-jsp-page

alternative approach

  1. add a new class to your web.xml, where you want to send your request/form data to. so your jsp would be 1 servlet, your other java class would be your other servlet.

  2. on your jsp, create a form that has an action of your new "testprogram" servlet


Related Query

More Query from same tag