게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
jsp에서 자바 클래스파일 import시 500 에러
게시물ID : programmer_12228짧은주소 복사하기
작성자 : casey
추천 : 0
조회수 : 4240회
댓글수 : 4개
등록시간 : 2015/07/20 21:58:10
자바에서 두 개의 파일을 임포트해 놓은 jsp를 실행시킬 때 다음과 같은 컴파일 에러메시지가 뜹니다.
임폴트를 잘못 시켰따고 하는 것 같은데, 상단에는 제대로 임포트 시킨 것 같은데, 뭐가문제일까요??

HTTP Status 500 - Unable to compile class for JSP:

type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:   An error occurred at line: [15] in the generated java file: [C:\03_Src\jsp\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\TwoDB\org\apache\jsp\pagination_jsp.java] Only a type can be imported. com.webapp.dbtodb.CityTransfer resolves to a package  An error occurred at line: 28 in the jsp file: /pagination.jsp CityTransfer cannot be resolved to a type 25: <body>  26: <% 27:      request.setCharacterEncoding( "utf-8");  28:      CityTransfer transfer = new CityTransfer(); 29:      List<City> citys =transfer.city(); 30: 	 31:      String pageNoStr = request.getParameter( "pageNo");    An error occurred at line: 28 in the jsp file: /pagination.jsp CityTransfer cannot be resolved to a type 25: <body>  26: <% 27:      request.setCharacterEncoding( "utf-8");  28:      CityTransfer transfer = new CityTransfer(); 29:      List<City> citys =transfer.city(); 30: 	 31:      String pageNoStr = request.getParameter( "pageNo");    Stacktrace: 	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102) 	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198) 	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450) 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:361) 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:336) 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:323) 	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585) 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363) 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 	org.apache.catalina.filters.ExpiresFilter.doFilter(ExpiresFilter.java:1201)

============================================================================================================
jsp 와 자바 클래스 두개의 소스는 다음과 같습니다.
============================================================================================================
<%@page import="java.util.ArrayList"%>
<%@page import="com.webapp.dbtodb.CityTransfer"%>
<%@page import="com.webapp.model.City"%>
<%@page import="java.util.List"%>
<%@page import= "com.webapp.util.Pagination"%>
<%@ page language ="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset= "UTF-8">
<title> pagination.jsp</title>
<style type= "text/css">

     .listnone {
            list-style: none;
     }

     .horizontal{
            display: inline-block;
     }

</style>

</head>
<body>
<%
     request.setCharacterEncoding( "utf-8");
     CityTransfer transfer = new CityTransfer();
     List<City> citys =transfer.city();
   
     String pageNoStr = request.getParameter( "pageNo");
     int pageNo=11;
     if(pageNoStr != null )
           pageNo = Integer.parseInt(pageNoStr);
          
          
     Pagination paging = new Pagination();
     paging.setPageNo(pageNo);
     paging.setTotalItem(citys.size());
%>

<ol>
     <li ><%= paging.getPageNo()%> /<%= paging.getTotalPage()%> </li > 
     <li >[ <%=paging.getTotalItem() %>] </li >                            
</ol>



<ul class="listnone">
     <%  
            if(!paging.isFirstGroup()){
     %>
    
            <li class = "horizontal"><a href= "pagination.jsp?pageNo=<%=paging.getFirstPage()-1 %>"><<이전 </a ></li >
               
     <%  
           }
     %>
    
     <%
    
            for ( int i=paging.getFirstPage(); i<=paging.getLastPage();i++){
     %>
    
            <li class = "horizontal"> <a href= "pagination.jsp?pageNo=<%=i%>" >[ <%=i %>] </a ></li >
    
     <%
           }
     %>
    
    
     <% 
            if(!paging.isLastGroup()){
     %>
    
            <li class = "horizontal"><a href= "pagination.jsp?pageNo=<%=paging.getLastPage()+1 %>">다음>> </a ></li >

     <%  
           }
     %>
</ul>


<ul>
     <%
            for ( int i=paging.getFirstItem();i<=paging.getLastItem();i++){
     %>
            <li ><%= i * 100%> </li >
     <%
           }
     %>
</ul>



</body>
</html>
=========================================================================================

package com.webapp.dbtodb;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.webapp.dao.CityDao;
import com.webapp.dao.EmpDao;
import com.webapp.exception.InsertRuntimeException;
import com.webapp.model.City;
import com.webapp.model.Emp;

public class CityTransfer {

   static String mClassName = "com.mysql.jdbc.Driver";
   static String murl = "jdbc:mysql://localhost:3306/world";
   static String muser = "world";
   static String mpassword = "1234";

   static Log log = LogFactory.getLog(CityTransfer.class);

   static void classLoader() {
      try {
         Class.forName(mClassName);
      } catch (ClassNotFoundException e) {
         e.printStackTrace();
         System.exit(-1);
      }
   }

   static void printCitys(List<City> citys){
      for(City c : citys){
         log.info(c.getId()
           + " " + c.getName()
           + " " + c.getCountry().getCode()
           + " " + c.getDistrict()
           + " " + c.getPopulation());
      }
   }
  


   public List<City> city(){
      classLoader();
      Connection mysql = null;
      try {
         mysql = DriverManager.getConnection(murl, muser, mpassword);

         CityDao dao = new CityDao(mysql);
         List<City> citys= dao.selectAll();
        
         for(City c : citys){
             log.info(c.getId()
               + " " + c.getName()
               + " " + c.getCountry().getCode()
               + " " + c.getDistrict()
                + " " + c.getPopulation());
          }
        
        
         log.info("Program normal exit...");
         return citys;
           
      } catch (SQLException e) {
         log.info("Connection fail...", e);
      } finally {
         try {
            if (mysql != null)
               mysql.close();
         } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
      }return null;
   }
  
}

=======================================================================================================

package com.webapp.model;

public class City {
   
    private Integer id;
    private String name;
    private Country country;
    private String district;
    private Integer population;
   
    @Override
    public String toString() {
        return "City [id=" + id + ", name=" + name + ", country=" + country
                + ", district=" + district + ", population=" + population + "]";
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Country getCountry() {
        return country;
    }
    public void setCountry(Country country) {
        this.country = country;
    }
    public String getDistrict() {
        return district;
    }
    public void setDistrict(String district) {
        this.district = district;
    }
    public Integer getPopulation() {
        return population;
    }
    public void setPopulation(Integer population) {
        this.population = population;
    }
       
}

전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호