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.

Similar Messages

  • Unable to compile class for JSP--- help me plz!!!!!

    hi friends;
    Pease suggest me where i am wrong, i think javabean is not instantiated in jsp file.may be it is related to the classpath of javabean. i have not set any variable for javabean classpath. and i put javabean class file in
    TOMCAT_HOME/webapps/test3/WEB-INF/UseDta.class
    and all the jsp and html in /test3. my jsp an javabeans are--
    1. GetName.html
    <HTML>
    <BODY>
    <FORM METHOD=POST ACTION="SaveName.jsp">
    What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>
    What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>
    What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
    <P><INPUT TYPE=SUBMIT>
    </FORM>
    </BODY>
    </HTML>
    2. SaveName.jsp
    <jsp:useBean id="user" class="UserData" scope="session">
    <jsp:setProperty name="user" property="*"/>
    </jsp:useBean>
    <HTML>
    <BODY>
    Continue
    </BODY>
    </HTML>
    3. UserData.java
    public class UserData {
    String username;
    String email;
    int age;
    public UserData(){}
    public void setUsername( String value )
    username = value;
    public void setEmail( String value )
    email = value;
    public void setAge( int value )
    age = value;
    public String getUsername() { return username; }
    public String getEmail() { return email; }
    public int getAge() { return age; }
    4. NextPage.jsp
    <jsp:useBean id="user" class="UserData" scope="session"/>
    <HTML>
    <BODY>
    You entered<BR>
    Name: <%= user.getUsername() %><BR>
    Email: <%= user.getEmail() %><BR>
    Age: <%= user.getAge() %><BR>
    </BODY>
    </HTML>
    url: http://localhost:8080/test3/GetName.html
    is it related to context path??
    HTTP Status 500 -
    type Exception report
    message
    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: 2 in the jsp file: /SaveName.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\test3\org\apache\jsp\SaveName_jsp.java:44: cannot find symbol
    symbol : class UserData
    location: class org.apache.jsp.SaveName_jsp
    UserData user = null;
    ^
    An error occurred at line: 2 in the jsp file: /SaveName.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\test3\org\apache\jsp\SaveName_jsp.java:46: cannot find symbol
    symbol : class UserData
    location: class org.apache.jsp.SaveName_jsp
    user = (UserData) jspxpage_context.getAttribute("user", PageContext.SESSION_SCOPE);
    ^
    An error occurred at line: 2 in the jsp file: /SaveName.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\test3\org\apache\jsp\SaveName_jsp.java:48: cannot find symbol
    symbol : class UserData
    location: class org.apache.jsp.SaveName_jsp
    user = new UserData();
    ^
    3 errors
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
    org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:437)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:497)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:476)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:464)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.
    Apache Tomcat/5.0.30
    please Reply me ASAP
    i'll be glad if you reply. please

    I am using Tomcat 6.0.
    I have put my UserData class in user package and
    used in below jsp(SaveName.jsp)
    <%@ page import="user.UserData" %>
    <jsp:useBean id="user" class="user.UserData" scope="session"/>
    <jsp:setProperty name="user" property="*"/>
    <HTML>
    <BODY>
    Continue
    </BODY>
    </HTML>
    I have already set my classpath as C:\Documents and Settings\user\My Documents\Java\apache-tomcat-6.0.16\apache-tomcat-6.0.16\webapps\ROOT\WEB-INF\classes;
    UserData class is in C:\Documents and Settings\user\My Documents\Java\apache-tomcat-6.0.16\apache-tomcat-6.0.16\webapps\ROOT\WEB-INF\classes\user
    My UserData class is
    package user;
    public class UserData {
    String username;
    String email;
    int age;
         public UserData(){
              this("","",0);
              System.out.println("najn thanne puli");
         public UserData(String username,String email,int age){
              this.username=username;
              this.email=email;
              this.age=age;
    public void setUsername( String value )
    username = value;
    public void setEmail( String value )
    email = value;
    public void setAge( int value )
    age = value;
    public String getUsername() { return username; }
    public String getEmail() { return email; }
    public int getAge() { return age; }
    But running SaveName.jsp shows exception
    org.apache.jasper.JasperException: /SaveName.jsp(2,0) The value for the useBean class attribute user.UserData is invalid.
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
         org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
         org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
         org.apache.jasper.compiler.Generator.generate(Generator.java:3372)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    Please help me.thanks in advance.

  • JasperException: Unable to compile class for JSP HELP

    I added couple of extra class files into the jar file.. and now its not able to find it! I am running JBoss latest version and using eclipse... any help wud be nice
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Only a type can be imported. org.jfree.chart.servlet.WebHitChart resolves to a package
    Generated servlet error:
    Only a type can be imported. org.jfree.chart.servlet.WebHitDataSet resolves to a package
    An error occurred at line: 10 in the jsp file: /bar_chart.jsp
    Generated servlet error:
    WebHitChart cannot be resolved
    An error occurred at line: 10 in the jsp file: /bar_chart.jsp
    Generated servlet error:
    WebHitDataSet cannot be resolved
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)

    just a random guess...
    I had a ton of issues with JBoss and jfreechart. JBoss uses a different classloader, and its internal versions of the jfreechart classes will be loaded before yours, causing all sorts of issues. Dig through the jboss directories and you'll find a different, older version of jfreechart of one of its classes. Remove them and you'll be in better shape.
    Alternatively, look around the JBoss docs for how to disable/turn off the unified classloader for your app (its a directive in jboss-web.xml IIRC). This should make the classloader for your webapp perform to spec, getting rid of the class colission issues.

  • 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

  • Importing class or jsp:useBean option

    Hi,
    I am bit confused as when to use between "beanClasses" or "tag librery" or "simple java classes useing import". as far as i feel all are capable of doing almost each others task (i.e excuting a method to process something). can anyone help me in understanding this

    Well, first, if I understand correctly,
    "simple java classes useing import"Would be using scriptlets to do the job. It is always best to avoid scriptlets, and the best way to do that is to
    use javabeans. So I would say use "beanClasses" over "simple java classes useing import" whenever humanly possible.
    On the other hand, I use tags and beans for different reasons. I use beans to transport data from one spot to another, such as through pages and requests, or to access non-display logic, like getting data from a database. I use tags mainly for complex display operations.
    For instance, lets use the oft-asked Paging question. I have a database with 500 records. I want to display 20 at a time in a JSP. I would use a Bean to get the information (and store it in a List of another Bean type). Then I would use a tag to do the [prev] 1 2 3 4 5 6 7 8 9 10 ... [next] display and links.
    Hi,
    I am bit confused as when to use between
    "beanClasses" or "tag librery" or . as far as i feel all are
    capable of doing almost each others task (i.e
    excuting a method to process something). can anyone
    help me in understanding this

  • 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

  • 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.

  • Importing classes in jsp

    In jakarta tomcat servlet engine, in which directory should I put a class file so that i can call it from a jsp located in /examples/jsp or where should I put the class file so that it can be called using <jsp:useBean> tag

    In jakarta tomcat servlet engine, in which directory
    should I put a class file so that i can call it from a
    jsp located in /examples/jsp or where should I put the
    class file so that it can be called using
    <jsp:useBean> tagI don't use Tomcat at the moment, but I think it's the same with resin and other stuff.
    You have a path called "/WEB-INF/classes" somewhere under your tomcat root. This is the location where you should store your classes and packages. The servers using only this path to locate classes, not your classpath.
    I hope, this helps.

  • Problem importing classes and beans

    Hey there. Im having one major fustrating problem! When I code supporting classes and beans for my JSPs I get a code 500 internal server error when trying to import (via <%@ page import="class" %> and <jsp:useBean/>) Im storing my classes and beans in the WEB-INF folder and the calling JSPs are located in /ROOT/tests/8/jsp.jsp. Im using the following to import a class or bean:
    <%@ import="aClass" %>
    Seen as tho its in the WEB-INF folder I won't have to explicitly refer to where the class is located, just the class name.
    I never had this problem when I was using my hosting service. Its only on my localhost server in which I get the Internal Server error.
    Help appreciated, thx.
    PS: Im quite new to JSP/Java Servlet.

    import (via <%@ page import="class" %> and
    <jsp:useBean/>) Im storing my classes and beans in the
    WEB-INF folder try put your class file in WEB-INF/classes.
    or first put bean in the package, like WEB-INF/classes/packagename/beanclass
    in jsp page:
    <jsp:useBean id="Mybean" class="packagename.beanclass" scope="request" />
    Question: is /ROOT a context entry in your server.xml?
    Which JSP Container (version) you use? Maybe your localhost server's set up is different with your hosting.

  • HELP: Import my own class in JSP ???

    Hi, all!
    I read many previous topics in this forum but no one works for me!
    Please someone help me!
    I'm using Tomcat 4.1.12 and my JSP scripts work just fine, but I need to import my own .class file. I just don't know where to put it so Tomcat can find it!?
    I have this environment variable:
    JAVA_HOME=.;c:\jdk1.3.1
    And in my code I'want to place something like this:
    <%@ page import="myClass" %>
    But I get a "can not resolve symbol" exception.
    Thanks for readind this, and please help if you can!
    Bye.
    adriano

    Within the Tomcat directory, under your application directory place the class file/s into the WEB-INF/classes directory. If your classes are part of a package place the entire directory structure of the package under the WEB-INF/classes directory.
    The import in the JSP is the same as for any Java class.
    Hope this solves your problem.

  • Help - import own classes in jsp

    Hey guys..
    I'm working on a Shopping cat project which is in the directory -
    C:\Tomcat 6\webapps\ROOT\cart
    I've written one code in shop-product.jsp as below -
    <%@ page language = "java" contentType = "text/html"
             import = "ShoppingBasket, Product, java.sql.*"
             errorPage = "errorpage.jsp" %>
    <html>
    <head> <title>Welcome to Shop</title></head>
    <body>
    <table width = "385" border="0" cellspacing="0">
    <tr>
    <td colspan="4">More Books from me</td>
    </tr><tr>
    <td colspan="4" align ="right">
    <a href = "<%=response.encodeURL("shop-basket.jsp") %>"> View Basket </a></td>
    </tr><tr>
    <td><b>Ref</b></td><b>Title</b></td>
    <td><b>Price</b></td></td></tr>
    <%
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    Connection connection = null;
    connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop", "root", "rahul");
    Statement stmt = null;
    ResultSet RS = null;
    stmt = connection.createStatement();
    RS = stmt.executeQuery("select * from items");
    int rowCounter = 0;
        while(RS.next())
          String item_id = RS.getString("id");
          String title = RS.getString("title");
          String desc = RS.getString("desc");
          String price = RS.getString("price");
          rowCounter=rowCounter+1;
          String bg=  (rowCounter % 2 !=0) ?"#C0C0C0":"#ffffff";
    %>
    <tr bgcolor = <%=bg%>">
    <td><%=item_id%></td>
    <td><b><%=title %></b><br/><%=desc%></td>
    <td><b><%=price %></b></td>
    <td>
    <a href =" <% response.encodeURL("shop-products.jsp?title="+title+"&item_id="+item_id+"&price="+price); %> "> Add to Cart </a></td>
    </tr>
    <% } RS.close(); connection.close(); %>
    </table>
    <jsp:useBean id = "basket" class = "ShoppingBasket" scope = "session"/>
    <% String title = request.getParameter("title");
       if(title!=null)
         String item_id = request.getParameter("item_id");
         double price = Double.parseDouble(request.getParameter("price"));
         Product item = new Product (item_id, title, price);
         basket.addProduct(item);
    %>
    </body></html>{code}
    in which ShoppingBasket and Product are the classes which I want to import. Where should I put those class files if my project path is 
    +C:\Tomcat 6\webapps\ROOT\cart+
    I've put class files into Tomcat_home/lib but it is giving me error
    {code}type Exception report
    message
    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: 6 in the generated java file
    The import ShoppingBasket cannot be resolved
    An error occurred at line: 7 in the generated java file
    The import Product cannot be resolved
    An error occurred at line: 62 in the jsp file: /cart/shop-products.jsp
    The method addProduct(Product) in the type ShoppingBasket is not applicable for the arguments (Product)
    59:      String item_id = request.getParameter("item_id");
    60:      double price = Double.parseDouble(request.getParameter("price"));
    61:      Product item = new Product (item_id, title, price);
    62:      basket.addProduct(item);
    63:    }
    64: %>
    65: </body></html>
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.{code}
    Please assist me on, how to import my custom made class files..
    Thanks,
    Rahul...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    What You need to do is to place ShoppingBasket class in a package and import to fully qualified class name (which is class name with package name). I also discourage You to use scriptlets - it's an obsolete, old technology.

  • Importing class in a jsp using Tomcat

    Hello All,
    Using Tomcat:
    I have class here:
    examples/WEB-INF/classes/ package/myclass.class
    I have a .jsp here:
    examples/JSPFolder/myjspfile.jsp
    I want to import the class into the jsp.
    I have tried the following combinations of importy lines based on previous posts on these boards and each have failed with same error:
    Unable to load class for JSP
    <%@ page import="myclass" %>
    <%@ page import="myclass.*" %>
    <%@ page import="package.myclass" %>
    <%@ page import="package.myclass.*" %>
    <%@ page import="WEB-INF/classes/package/myclass%>
    I have seen a number of posts for this same problem, and have tried those solutions as well, but none work. I am sure that this is simply a problem of finding the right directory, as I can successfully run the .jsp file iwhen I remove the import line.
    Can someone please help?

    There is a folder for shared packages
    tomcat_root\lib; or
    tomcat_root\common
    also most versions have a lib or common folder for each webapp for packages that are not to be shared.
    tomcat_root\webapps\appname\web-inf\lib
    Agreed that it is strange to allow servlets to import from the classes foler but not JSPs. It should make no difference but it is convension to place single classes in the same folder as the app's directory and packages (especially jar's) in the lib directory.

  • Using an imported class in a JSP file

    When you import a class you wrote into a JSP file, is there a way to submit values from forms to the entire class, or can you only use the methods within the class??

    When you import a class you wrote into a JSP file, is
    there a way to submit values from forms to the entire
    class, or can you only use the methods within the
    class??Yes, there is a way in JSP. You can use,
    <jsp:useBean id="your_bean_id" scope="page or request etc" class="your_class">
    <jsp:setProperty name="your_bean_id" property="*"/>
    </jsp:useBean>
    So, <jsp:setProperty> sets all the values inside your request object into the bean, if the class is having the properties (variables) with same name as of request object's parameters. You must have coded set method for all the properties whatever you want your jsp to set the values in the bean.
    if your request is .../yourjsp?name=xxxx&age=25
    then <jsp:setProperty> method will set the name and age inside bean if you have,
    public class YourBean {
    String name;
    int age;
    public void setName(String name) {
    this.name=name;
    public void setAge(int age) {
    this.age=age;
    Hope this helps.
    Sudha

  • NullPointerException - importing my own class to JSP

    Hi.
    I'm writing a JSP page. I also made a class in WEB-INF/classes/org/MyXml.class. When I try to run this class from console, there is no problems at all. But if i try to use function from that class in JSP, i get this (the same error i get whichever function i try to use (btw, all functions are static, as they should be, right?)):
    java.lang.NullPointerException
         org.MyXml.CountProducts(MyXml.java:46)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:75)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    I used this class like this:
    <%@ page import="org.MyXml" %>
    <%
    MyXml.CountProducts();
    %>
    I'm also a bit confused, it says that error is on line 46. Well, there's just a comment!
    Please help. Thanks.

    pqeuens,
    MyXml is his class. his methods are static, so, import="org.MyXml.*" won't work. It would either be import="org.*" or import="org.MyXml" (which he has)
    paull1911
    "What file are you looking at to find line 46? It is the java file (a servlet) corresponding to the jsp file."
    It should actually be in the org.MyXml.java file. The stack trace line is:
    java.lang.NullPointerException
    org.MyXml.CountProducts(MyXml.java:46)
    someone_
    You know from the above error line that the error is in MyXml.CountProducts method. After making sure you are working with the most up-to-date version of the class, (if that doesn't help you get a more accurate line number) walk through the CountProducts method and see where you might be trying to access an object that has not yet been instantiated (either using someObject.someMethodOrMember, or someArray[index])

  • 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

Maybe you are looking for

  • Confirmations the Purchase Order ?

    Hi Experts, How to do the conformation of Purchase order at a time for all the line items with same date. i mean if one PO  having 10 line itmes..  vendor conformed for all the 10 line item materials same date . so no need to enter different  line at

  • Is Multi Mapping will work with  node function useAsMany with SP10 ?

    Hi friends,                 I  am  working some sample Multi Mapping scenario . My XI 3.0   SP is  10 .                 I am getting the following error , while i am testing the Mapping with <b>useAsMany Node function </b> it  is giving the Following

  • Where is WebDBM, the web tools package?

    I am looking for it. It was listed on the old SapDB site, up to version 7.4, and now I see trace of the GUI, Studio, but where is the WEBDMS for MaxDB 7.6? Thanks!

  • 9.4.2 update: Merge word docs into pdf BROKEN

    While I am not experiencing the printer problems a lot of users are complaining about after the (so called) "update" to 9.4.2, another (for me) essential function is broken. When I try to merge a couple of supported files into one pdf, the process wi

  • Reinstalled Leopard, battery life *****...

    I decided to wipe my Santa Rosa MacBook's HD this weekend and reinstall this weekend. I had been working with the factory install since I bought it in December up until now. Once I finished getting the system back with all my apps reinstalled, I noti