기술지원 문의

jsp에서 bean 패키지를 import시킬때 클래스를 못찾네요.
김현택 / 2003-04-21 00:00

beantest.jsp파일입니다.
<%@ page import = \"hello.*\" %>



<%
   String str = null;
   HelloBean myhello = new HelloBean();
   myhello.setStatement(\"JSP Bean Test!!!~\");
   str = myhello.getStatement();
   out.println(str);
%>





bean파일
package hello;

public class HelloBean
{
   private String statement = \"\";
   public String getStatement()
   {
      return statement;
   }
   public void setStatement(String statement)
   {
      this.statement = statement;
   }
}

localhost/beantest.jsp를 브라우저에 실행시키니 자동으로 컴파일이 되어 hello폴더에 HelloBean.class파일이 생성되네요. 그런데 실행을 시키면 HelloBean클래스를 찾지 못하네요. 우선은 import부분을 import=\"hello.HelloBean\"이런식으로 바꿔주거나 빈 클래스 객체를 생성하는 부분에서 
hello.HelloBean myhellobean = new hello.HelloBean();이런식으로 바꿔주면 되긴 되는데.. 패키지 내에 여러 클래스 파일이 있다면 조금더 효율적인 방법이 import=\"hello.*\"이 아닐까 합니다.
제가 모르는것이 자바인지 jsp인지 모르겠지만 고수님들께서 한 수 가르쳐 주십쇼.

Re:jsp에서 bean 패키지를 import시킬때 클래스를 못찾네요.
관리자 / 2003-04-22 00:00

hello라는 디렉토리가 어디에 생겼나요?

WEB-INF/classes/hello라고 생기고 
거기에 HelloBean.class가 있으면 말씀하신 것이
맞는 것 같습니다. 혹시 resin의 설정을 디폴트로
사용한다면 HelloBean.java도 
WEB-INF/classes/hello 디렉토리에 있어야 합니다.
확인해보세요.


--김현택 님의 글 [2003-04-21 00:45:14]
>beantest.jsp파일입니다.
<%@ page import = \"hello.*\" %>



<%
   String str = null;
   HelloBean myhello = new HelloBean();
   myhello.setStatement(\"JSP Bean Test!!!~\");
   str = myhello.getStatement();
   out.println(str);
%>





bean파일
package hello;

public class HelloBean
{
   private String statement = \"\";
   public String getStatement()
   {
      return statement;
   }
   public void setStatement(String statement)
   {
      this.statement = statement;
   }
}

localhost/beantest.jsp를 브라우저에 실행시키니 자동으로 컴파일이 되어 hello폴더에 HelloBean.class파일이 생성되네요. 그런데 실행을 시키면 HelloBean클래스를 찾지 못하네요. 우선은 import부분을 import=\"hello.HelloBean\"이런식으로 바꿔주거나 빈 클래스 객체를 생성하는 부분에서 
hello.HelloBean myhellobean = new hello.HelloBean();이런식으로 바꿔주면 되긴 되는데.. 패키지 내에 여러 클래스 파일이 있다면 조금더 효율적인 방법이 import=\"hello.*\"이 아닐까 합니다.
제가 모르는것이 자바인지 jsp인지 모르겠지만 고수님들께서 한 수 가르쳐 주십쇼.