File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Compilation error on importing class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Compilation error on importing class" Watch "Compilation error on importing class" New topic

Compilation error on importing class

James Zhang
Ranch Hand

Joined: Sep 06, 2002
Posts: 30
I need help to figure out what is wrong with my testing jsp page as below:
<%@ page import="AddressBean" %>
<jsp:useBean id="address" class="AddressBean" scope="session" />
<jsp:setProperty name="address" property="*" />
The address is <br><jsp:getProperty name="address" property="street" /><br>
<jsp:getProperty name="address" property="city" />,
<jsp:getProperty name="address" property="state" />
<jsp:getProperty name="address" property="zip" />
The AddressBean.class has been compiled correclty and is placed under WEB-INF\classes.
When the jsp page is loaded (either by other jsp page or loaded directly), I always got a compilation error for the first line:
C:\bea\user_projects\domains\SimpleBean\.\myserver\.wlnotdelete\extract\myserver_jspapp3_jspapp3\jsp_servlet\ '.' expected
probably occurred due to an error in /address.jsp line 1:
<%@ page import="AddressBean" %>
It is quite confusing. Anybody has similar experience? By the way, I am using Weblogic as my server.
Thanks in advance!
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
You are not using import correctly, import needs a package and ALL classes used in JSP or servlets should be in packages. (Yes, I know you can sometimes avoid it, but trust me on this.)
Instead of:

use a package in both import and useBean:

James Zhang
Ranch Hand

Joined: Sep 06, 2002
Posts: 30
Bill, thanks a lot for your quick reply and excellent suggestion! I made the change and it works now!
Thanks again!
I agree. Here's the link:
subject: Compilation error on importing class
It's not a secret anymore!