Can't import class into JSP

Hi,
I am trying to import a class into my JSP and am getting the following error at runtime:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Compiling 1 source file
[javac] D:\jwsdp-1.2\work\Catalina\localhost\pe\org\apache\jsp\guestbook_jsp.java:7: '.' expected
[javac] import MessageGetter;
My import statement in the JSP is simply:
<%@ page import="MessageGetter" %>
and I am placing the class in the WEB-INF/classes directory. This is stumping me - if you've come across this or a similar problem, please let me know. Thanks.
P

Try posting your question in the JSP forum (http://forum.java.sun.com/forum.jsp?forum=45)
cheers,
Mike

Similar Messages

  • Importing classes into JSP page

    Hi There,
    I am new to this and here is my problem.
    I am doing a shopping cart tutorial and trying to get a JSP page to import two classes :
    <%@ page language="java" contentType="text/html"
    import="ShoppingBasket,Product"
    errorPage="errorpage.jsp" %>
    I get :
    C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\_\shop_0002dbasket_jsp.java:7: '.' expected
    import ShoppingBasket;
    ^
    C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\_\shop_0002dbasket_jsp.java:8: '.' expected
    import Product;
    ^
    C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\_\shop_0002dbasket_jsp.java:50: cannot resolve symbol
    symbol : class ShoppingBasket
    location: class org.apache.jsp.shop_0002dbasket_jsp
    ShoppingBasket basket = null;
    The classes compile ok . I read that instead of comma seperating the classes it might be better to put them in a package but I do not know the correct syntax or where to put the package if this is correct.
    The tutorial is from this book and the shopping cart source code is here.
    http://www.ineasysteps.com/books/?1840781971
    Any help appreciated
    Jim Ascroft

    A little beginners explanation of classpaths and packages is in order here. A package works like an extension of the name to keep class names unique. For example, if you have a ShoppingBasket.class and you want to use my ShoppingBasket.class along with it the two class names must be unique or different from one another in some way. Yours could be in com.yourcompany package and mine could be in org.mycompany package. When you reference you Shopping backet in your code you would use com.yourcompany.ShoppingBasket and when you reference mine in the same code you would use or.mycompany..ShoppingBasket. Shorthand for the class can be used by adding an import at the top of the referencing java file. An import is like saying "hay compiler, whenever you see ShoppingBasket look for it in the com.mycompany package!" That brings us to the next point. The package name must always be reflected in the directory structure of the .class file location in order to be found. Your shopping basket must be stored under the directory com/yourcompany if it is in package com.yourcompany. That directory structure should extend off of a classpath entry in order to be made available to the JVM. Classpath entries point to folders, jar or zip files that contain packaged and unpackaged classes. So If you have a classpath entry that points to C:\jakarta-tomcat-4.1.30\webapps\ROOT\WEB-INF\classes then all unpackaged classes (classes compiled from a .java file without a package statement) will be pulled directly out of this folder. Also, packaged classes will be pulled out of they're packaging directory structure, which should be located in this folder. You can have as many classpath entries as you want but the classes will be pulled out of the first entry that they can be found under. Now with a web app you don't normally fuss with the setting of classpaths since they are already predefined and configured for you. You just need to know to put all of your class files under the WEB-INF/classes directory in the root of your web app. You do, however, still need to know how they work. You also should know that any jar files should be placed in the lib folder of your web app and not under the classes folder.
    Getting back to your immediate problem, why are you getting class not found errors? Well this stems from what was said above. To fix these kind of problems follow these steps:
    1st off, find out exactly which .java file the .class file was compiled from. (This can be a problem in some environments where multiple copies of source hang around.) This step may involve a recompile and paying close attention to the compiler arguments. In an IDE there should be a setting or dialog that lets you find out exactly where it's placing the .class files created from you source.
    Next, determine what package the .class file should be in by examining (and maybe changing) the package statement at the top. For example, if you intended to put ShoppingBasket in the com.bloodoo package make sure it has a package "com.bloodoo;" statement at the top.
    Next recompile the .java source and move the packaging directory structure into the classes folder of your app. (This would be WEB-INF/classes under the root of the web-app.) For example if ShoppingBasket.class was compiled into the com/bloodoo folder under C:\Program Files\YourIDE\projects\yourproject\output then copy the com folder out of the output folder and into the WEB-INF\classes folder.
    Next examine the calling code (JSP or servlet .java code) and make sure it references the problem class out of the right package. For example, yourpage.jsp should reference the class com.bloodoo.ShoppingBasket and not ShoppingBasket if the shopping basket is deployed in package com/bloodoo. This gets tricky with jsp usebean tags because the desire is to use shorthand but I'm not sure if that works with the use bean tag. Make any modifications and recompile if necessary.
    Lastly, as a rule of thumb avoid wild-card imports (eg. import com.package.*) because they are a common cause of confusion especially when refactoring package names and resolving these kind of issues.Those steps should allow you to resolve 85-90% of your class not found issues. The other 10-15% are rare cases involving the use of custom classloaders, the Java extension mechanism and/or classpath trickery. If you still have questions/problems post back.
    Cliff

  • ACK! Importing classes in JSP?!?! HELP!!!

    I am REALLY new to the JSP world and just finished creating a java applet that creates a graph and two combo boxes containing information that I need to display on a web page.
    The problem is that I have just been told to convert it to JSP? Is this possible? If it IS possible, how do you import a public class into JSP?
    Thanks sooooo much for your help!!!!!
    Adam

    Answer is yes you can import a java class
    Here is how it works
    use the following
    <%@ page import="com.temp.YourClass*" %>
    Assuming that you classpath is set properly
    Thanks
    Sampath Thummati.

  • I can not import photos into lightroom 4.4  Had no problem before this time.

    I can not import photos into lightroom 4.4  Had no problem before this time.  I have camera raw7.4 and use a NikonD7100.  I have a Mac using 10.6.8.  I can see the images and selected for import in Lightroom, but after I check "import" I get a message that Lightroom could not read the files.  This happens with both raw and jpeg files.  Thanks for a repl

    thanks for the reply. would you please tell me how to check for the folder to have write permission.  I have done the same settings as before but this time does not transfer.  It says can not read files with a code "298".  I can see the thumbnails on the screen prior to trying to import the photos, also can see them with the card in the camera and using the view mode.  I have up to date camera raw 7.4 for my Nikon D7100 and the settings allow for 7.1 and above

  • How can I import video into iMovie from a DVD?

    How can I import video into iMovie from a DVD?
    Thanks,
    Doug Davis

    You can do this with a free app called MPEG Streamclip and a $20 quicktime component from Apple.
    See detailed instructions here.
    https://discussions.apple.com/docs/DOC-3951

  • How can I import music into iTunes from other media .I have music which was downloaded from my Sony Ericcson W715 into "Media Go" and I want to transfer it into iTunes.Is this possible ?

    How can I import music into iTunes from another media.
    I have a library downloaded from a Sony Ericsson W715 into "Media Go" and I want to transfer to iTunes and then into my iPhone 4.
    Is this possible ?
    Chris
    <Email Edited by Host>

    chrisfromgoodworth clatford wrote:
    How can I import music into iTunes from another media.
    I have a library downloaded from a Sony Ericsson W715 into "Media Go" and I want to transfer to iTunes and then into my iPhone 4.
    Is this possible ?
    Chris
    Possibly. Media Go supports a variety of music formats, some of which can be imported in to iTunes and then synced on to an iPhone, however some of its formats cannot be imported in to iTunes.
    See http://mediago.sony.com/enu/supported-file-formats/ for a list of formats supported by Media Go. iTunes for Windows supports MP3, AAC, WAV, and can import and convert WMA files as well. However iTunes does not support ATRAC, or FLAC.
    Furthermore, if some of your music has been bought from an Internet music store it might be procted by DRM. If so it cannot be imported in to iTunes.
    To do the importing you would either drag the music files in to iTunes, or tell iTunes to open them. See http://support.apple.com/kb/ht1347

  • I took a 15 minute video clip on my phone and now I can't import it into iphoto.  I've been able to import clips to iphoto in the past.  How do I fix this?  How can I get it imported onto my MacBook and ultimately iMovie?

    I took a 15 minute video clip on my phone and now I can't import it into iphoto.  I've been able to import clips to iphoto in the past.  How do I fix this?  How can I get it imported onto my MacBook and ultimately iMovie?

    Maybe try one of the WiFi transfer Apps?  There are several to choose from. I use Photosynch quite often to send photos and videos between my computer(s), my iPhone, and iPad.

  • I have Calendar v 7.0 and Entourage 12.3.6 2008 on OS X 10.9.2. I cannot import Entourage events into Calendar - this was never an issue with iCal. Whats happened and how can I import details into Calendar or do I need iCal back?

    I have Calendar v 7.0 and Entourage 12.3.6 2008 on OS X 10.9.2. I cannot import Entourage events into Calendar - this was never an issue with iCal. Whats happened and how can I import details into Calendar or do I need iCal back?

    adamboettiger wrote:
    Sophos and MacKeeper
    There are many reported problems with both these programs.
    Run through this list of fixes in order, will tune you right up.
    They are in order for a reason.
    ..Step by Step to fix your Mac

  • Have updated to yosemite and now can't import tiffs into illustrator

    Have updated to yosemite and now can't import tiffs into illustrator. Help!

    sued,
    It is known that there are CS4/Yosemite issues.
    For your issue, you may try to save your TIFF as a Photoshop .eps file and import that.
    Or a rollback to Mavericks.

  • Importing classes into a jsp

    I have created a class file called BindListener.java and put it in my root directory in my web module. I cannot however get the import statement for the jsp right, my root directory is called JBuilder. I have tried putting it in the WEB-INF classes folder also but still when I try to execute thr jsp it dosent work.
    There is no package declared in the classs file and it does not extend any other class, however it implements the HttpSessionBindingListener interface.
    I can call servlets from my JSP in the WEB-INF classes dir using /JBuilder/ServletName
    I am mondo confused please help

    I have created a class file called BindListener.java
    and put it in my root directory in my web module. I
    cannot however get the import statement for the jsp
    right, my root directory is called JBuilder. I have
    tried putting it in the WEB-INF classes folder also
    but still when I try to execute thr jsp it dosent
    work.
    There is no package declared in the classs file and
    it does not extend any other class, however it
    implements the HttpSessionBindingListener interface.You have to put the class in a package, then put the .class file in a package directory under WEB-INF/classes. So for example:
    package beans;
    public class BindListener ...
    //goes into this directory structure
    <APP_ROOT>/
      *.jsp
      WEB-INF/
        web.xml
        classes/
          beans/
            BindListener.class
    //And is imported into your JSP using one of the following
    // -- EITHER --
    <%@ page import="beans.BindListener" %>
    <%
      BindListener bl = new BindListener();
    %>
    // -- OR --
    <jsp:useBean id="bl" class="beans.BindingListener"/>>
    I can call servlets from my JSP in the WEB-INF
    classes dir using /JBuilder/ServletName
    I am mondo confused please help

  • Importing class to JSP in websphere (newbie)

    Hi I am trying to figure out how to properly import a class in a JSP.
    The DocumentRoot directory is set in Websphere and that is where my JSP's reside. I have created a folder off of the DocumentRoot directory called classes and placed my .class file in there. I then set the classes directory in the classpath (and restarted the appserver)
    I have an import statement in my jsp for the class.
    I am now getting an error that says it is unable to compile because of null. Any ideas????
    Below is a test piece of JSP code and the class code:
    <%@ page import="java.io.*, java.util.*, java.text.*, IPRStat, java.net.*,java.sql.*"%>
    <HTML>
    <BODY>
    <%
    try {
    String IPRNum = "001-0001";
    String IPRStatus = "OK";
    IPRStat Testing = new IPRStat(IPRNum, IPRStatus);
    } catch (Exception e) {
    out.println("Error detected " + e.getMessage());
    %>
    </BODY>
    </HTML>
    class IPRStat
    public IPRStat(String i, String d )
    iprnum = i;
    status = d;
    public String getIPRNum()
    return iprnum;
    public String getStatus()
    return status;
    private String iprnum;
    private String status;
    -----------------------------------------------------

    DocumentRoot (looks something like: /aibm/Userdata/WebAsAdv/default/mydev) is where my JSP's live (i.e.)
    /aibm/Userdata/WebAsAdv/default/mydev/testidea.jsp
    and I made a directory off of DocumentRoot called classes:
    /aibm/Userdata/WebAsAdv/default/mydev/classes
    And copied IPRStat.class into the classes directory.
    /aibm/Userdata/WebAsAdv/default/mydev/classes/IPRStat.class
    I then put the path (/aibm/Userdata/WebAsAdv/default/mydev/classes) in the classpath and restarted the appserver.
    At this point there is no Web-INF that I can see. I am new to Websphere myself. Is version 3.5.4 standard edition. I am using the websphere admin console to set the classpath.

  • Java class into jsp page

    hi i,m a beginnner
    how can i run my own java class into a JSP file?
    please help me!
    thanks

    If you understand the OO concepts and wrote the Java class right, then all you need to do is something like:YourJavaClass yourJavaClass = new YourJavaClass();
    yourJavaClass.doSomething();After all I rather recommend to use servlets for business logic instead of JSP (read: scriptlets).

  • How to import classes into labview project?

    Hi everyone 
    I start objected oriented program with labview, I have two sample project and I want to import their classes into my new project? is it possible to do that ? how can I import them ?
    thanks 

    You can simply add them like you would any other VI or library. I would recommend creating a virtual folder for your classes so you can keep your project organized.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Can't import loops into LPX that import fine into Logic 9

    Hi all,
    I'm new to posting to the forum but have learned a great deal from browsing it over the last few years. I've got a question that I've scanned the forum for but can't seem to find an answer to. My problem is this: I've got loops that will import fine into the loop library in Logic 9 but absolutely will not show up in Logic Pro X (10.0.4). I'm running OSX 10.6.8 on a late 2013 MBP (15", 16GB RAM, 512SSD).
    These are loop collections that I've purchased from a couple of different reputable companies. Some are in .wav format, others .aiff. I've tried reindexing the loop library, editing the loops individually and as a group in ALU to make sure that they're listed as loops and have the proper collection and naming parameters (all do), etc... Nothing seems to be working. I just drag and drop the folder in LP9 and it works great, but when I try to do the same in LPX, nothing happens.
    I'm running my loops through an external harddrive (with an alias on a local folder pointing to the external hard drive), but even when I try to store loops locally it doesn't make a difference.
    Does anyone have any ideas/tips? Has anyone else heard of anything like this? For what it's worth, I have just shy of 40,000 loops in LPX (and nearly 50,000 in LP9)... not sure if there's a limit, but it wouldn't make sense that a previous version would allow more loops.
    Any advice would be greatly appreciated. Thanks!

    Logic Pro X is not compatible with 10.6.8 so how did you download/install it?
    LPX requires a minimum of 10.8.4 to download/install correctly.....
    This may be the cause of your issue......

  • How can I import pictures into an existing event?

    I am loading up my new MAC with various photos on CDs and would like to be able to import them into specific existing events, instead of creating a new event and dragging it to merge with another. How can I do this?  If not, is there an easy way to merge events without dragging from one end of the list to another - hard when you have a couple of hundred events.

    You can't.  All import will go into a new event.  Then you can drag that event onto the Event you want to put the photos in and that will merge the two.
    OT

Maybe you are looking for

  • Stock report for a specific date.

    Hi Gurus, Can any one please tell me if there is any option is SAP by which i can get the stock status for a particular day. I mean if i want to check what was the stock report on last week some day, is there an option in SAP to do that. This report

  • [SOLVED]: Install OracleSolaris 11 on the DELL laptop

    Hi, ALL, I don't know if this question belongs here, but here goes... I downloaded an Oracle Solaris 11 image and trying to install the system on my DELL Inspiron laptop. The machine boots up but in the console mode. I can communicate with the instal

  • Trouble loading an external swf file implemented with AS3

    I am using Adobe Flash CS3 At first, I tried swf_mc.loadMovie("//swf file location"); It gave me quote: Warning: 1060: Migration issue: The method loadMovie is no longer supported. USE: var l = new Loader(); addChild(l); l.load(new URLRequest("your u

  • Strange error while calling BAPI_USER_LOCK

    When I call BAPI_USER_LOCK method, for a particular system which is nw2004s, it gives an error "External ID maintenance is no longer available". I am using SAP .net connector to call the BAPI, is this because some setting need to be changed on the ta

  • CRM_IC new view

    Hi experts, I need your help to resolve a problem. I have to create a new view in transaction BSP_WD_WORKBENCH. I have tried to create view putting in Model Notes Fields this datas: Model Notes -   BOL Entity -  Higher-Level   -     BOL Realtion BTOR