1
<%@page import="<PackageName>.*" %>
<%@page import="java.util.ArrayList" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>

<%  
int propertyCount=0;
ArrayList<String> MsgFlow =new ArrayList<String>();
ArrayList<String> ProValue= new ArrayList<String>();
ArrayList<String> PropertyKey= new ArrayList<String>();
if(request.getAttribute("Populate")!=null){

BeansOverride beans = new BeansOverride();
beans = (BeansOverride) request.getAttribute("Populate");

MsgFlow = beans.getMsgFlows();  
ProValue = beans.getProValue();
PropertyKey = beans.getPropertyKey();
MsgFlow.add("Abd");
ProValue.add("Name");
PropertyKey.add("Fjrk");

propertyCount = MsgFlow.size();
}
%>

error

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: 18 in the jsp file: /Home.jsp
BeansOverride cannot be resolved to a type
15: ArrayList<String> PropertyKey= new ArrayList<String>();
16: if(request.getAttribute("Populate")!=null){
17: 
18: BeansOverride beans = new BeansOverride();
19:     beans = (BeansOverride) request.getAttribute("Populate");
20:     
21:     MsgFlow = beans.getMsgFlows();  
Prasad Kharkar
  • 13,410
  • 5
  • 37
  • 56
uniswift
  • 21
  • 2
  • 5
  • 1
    You need to import class `BeansOverride`! – Shashank Kadne Sep 11 '13 at 07:14
  • when imported class file i got this error.......... org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [14] in the generated java file: [C:\Program Files\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\BlueShieldBarOverride\org\apache\jsp\Home_jsp.java] Only a type can be imported. com.cts.BeansOverride resolves to a package – uniswift Sep 11 '13 at 07:16
  • Maybe `com.cts.beansoverride.BeansOverride` or so?. By the way you may write `<%@page language="..." import="..." import="..." ... %>` (with linebreaks likely). – Joop Eggen Sep 11 '13 at 07:40
  • @Joop: the "resolves to a package" error from JSP compiler while you're 100% positive of the valid FQN is under the covers a simple `java.lang.NoClassDefFoundError`. This should give sufficient hint where the problem is. – BalusC Sep 12 '13 at 01:17
  • 1
    user2767622: I warmly recommend you to stop writing Java code in JSP files. [This technique is completely obsolete](http://stackoverflow.com/a/3180202). Write Java code in a real Java class. In this particular case, you need to create a [servlet](http://stackoverflow.com/tags/servlets/info) and put the code in `doGet()` method. You'll ultimately not only end up with more simple, clean and easy-to-maintain code, but you'll also get more clear compiler errors and runtime exceptions which are more easy to understand and fix than those cryptic JSP *scriptlet* errors. – BalusC Sep 12 '13 at 01:20

1 Answers1

0

It can not find the class BeansOverride

Change

<%@page import="<PackageName>.*" %>

so that it includes the package of BeansOverride

based upon your comments, you need to match the class package name with the jsp import name.

So. Change class to

package com.cts;

As mentioned in What's the syntax to import a class in a default package in Java?

It is illegal to import a class from

Community
  • 1
  • 1
Scary Wombat
  • 44,617
  • 6
  • 35
  • 64
  • geting same error::: BeansOverride cannot be resolved to a type – uniswift Sep 11 '13 at 07:18
  • So what classes in the packages BeansOverride do you want to use? Is the class availblee for your webapp (on the classpath)? – Scary Wombat Sep 11 '13 at 07:25
  • BeansOverride is a class, its not a package...... how to know that class is available in webapp??? – uniswift Sep 11 '13 at 08:44
  • According to the error you posted 'com.cts.BeansOverride resolves to a package' so maybe it should be 'com.cts.BeansOverride.BeansOverride'? – Scary Wombat Sep 11 '13 at 08:49
  • Go on, show me the code of BeansOverride.java. And also what you have changed your JSP topline to. – Scary Wombat Sep 11 '13 at 08:58
  • public class BeansOverride { String BarPath; String PropetyPath; ArrayList MsgFlows = new ArrayList(); ArrayList ProValue= new ArrayList(); ArrayList PropertyKey= new ArrayList(); String INPUT_ZIP_FILE; ArrayList Development = new ArrayList(); ..............and their setter and getter method............... } – uniswift Sep 11 '13 at 09:02
  • <%@page import="com.cts.BeansOverride"%> <%@page import="java.util.ArrayList"%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> BAROVERRIDE GENERATOR <% int propertyCount=0; ArrayList MsgFlow =new ArrayList(); if(request.getAttribute("Populate")!=null){ – uniswift Sep 11 '13 at 09:04