JSP:useBean in Tomcat with external libraries

Hi!
I would like to use netbeans 4.1 for developing jsp-pages, but are facing a problem when trying to use the built-in jsp compiler.
in my code I use something like:
<jsp:useBean id="id" class="package.Classname" scope="application" />while package is an external package initially created from JAXB. To include it into netbeans, I have put the directory containing all the classes into the build libraries and also into the test libraries. In the 'Projects'-Explorer it shows all the classes contained.
When I try to run the jsp-File, I get an error like this:
Compiling 1 source file to C:\Develop\ApplicationDescriptionGenerator\build\generated\classes
C:\Develop\ApplicationDescriptionGenerator\build\generated\src\org\apache\jsp\general_jsp.java:48: cannot find symbol
symbol: class Classname
location packageI do not understand this behaviour, especially, as the 'web' folder created by netbeans includes all necessary classes, and when I copy it to my tomcat installation, it works fine.
Does anybody know, what I have to change, so that I can test it from inside netbeans?
Thanks a lot!

Here is the java program or bean class that I'm using, UserData.java compiled into UserData.class:
public class UserData {
String username;
String email;
int 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; }
To put the data into the session, I used the following form:
<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>
and SaveName.jsp is this:
<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
Continue
</BODY>
</HTML>

Similar Messages

  • JavaFX with external libraries

    Hi,
    I would like to get some help about compiling a JavaFX code with external libraries. I've searched around a lot, but cant find the solution.
    Basically I have a JavaFX application, that uses images (they are under the src/ folder as they suggest it) and uses external .jar files, AND these jar files uses other external files (not jars). I want to run the application in desktop mode first, so now I am interested in a solution that makes it work on PC.
    I am using Netbeans to develop and run (works everything fine when running from IDE), and using javafxpackager to compile, when I want to run without the IDE.
    When I compile with Netbeans, the generated jar and jnlp files can run ONLY from the dist/ folder, if I copy it somewhere else in my winchester, it does not start.
    I have find something about "signing jars", so I have to make the jars signed to be able to run them AND to be able to link to the image files that the application uses.
    So I have 2 problems/questions with this situation:
    - I have to use external jars and those jars uses external files, but when I start the app, it seems its __DIR__ variable is not set correctly, but I've read that I have to make the application "signed" to solve this problem, but
    - if I make the JavaFX signed, it requires that all other jars have to be signed? (it sounds logical of course)
    So, my final question is, do I have to make the application (and all other jars) signed, to be able to use external jars and files or not (if I want to run as a desktop application)?
    And if I have to make them signed, then will the relative linking work correctly?
    So whats the best way to make it work (using external files and jars)?
    Thanks for any help, and sorry for the long post (and for my bad english) :)
    Cheers
    kojak

    kojak wrote:
    When I compile with Netbeans, the generated jar and jnlp files can run ONLY from the dist/ folder, if I copy it somewhere else in my winchester, it does not start.Unfortunately JNLP requires the base location to be stored in the JNLP file. While that supposedly makes JNLP distributed stuff more secured, it also make them cumbersome and time-consuming to use.
    Futhermore, JNLP files generated by NetBeans reference a local web server that only runs when NetBeans is on.
    That explains why you just simply cannot move the app to the location you want. I you move them, you have to open them (any text editor) and modify the codebase field (possibly the homepage's href too).
    If you want to use only 1 single JNLP, all your JARs references in that JNLP need to be signed with the very same certificate (certificate A).
    Unfortunately, this is not good most of the time as some external lib (generally the ones coming from Sun/Oracle) are already signed and you cannot resign them.
    The other option is that you can make your main JNLP reference other sub-JNLP that are placed at the same location. Each of these sub-JNLP can reference 1 or more JARs that are signed with a different certificate (1st JNLP used certificate B, 2nd JNLP used certificate C, etc.).
    An example adapted from my own main JNLP:
    <resources>
        <java version="1.6+"/>
        <jar href="http://<intranet web server>/<my main JAR file>" download="eager" main="true"/>
        <extension href="http://dl.javafx.com/1.3/javafx-rt.jnlp" name="JavaFX 1.3.x Runtime"/>
        <extension href="http://<intranet web server>/l2fprod-7.3.jnlp" name="l2fprod-7.3"/>
        <extension href="http://<intranet web server>/JFXtras-0.7.jnlp" name="JFXtras-0.7"/>
        ...and JFXtras-0.7.jnlp:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://<intranet web server>" href="JFXtras-0.7.jnlp">
        <information>
            <title>JFXtras-0.7</title>
            <vendor>JFXtras</vendor>
            <homepage href="http://code.google.com/p/jfxtras/"/>
            <description>Additionnal controls for JavaFX</description>
            <offline-allowed/>
        </information>
        <security>
           <all-permissions/>
        </security>
        <resources>
           <jar href="lib/JFXtras-Common-0.7rc2.1.jar" main="false" download="eager" size="1309380"/>
           <jar href="lib/JFXtras-Controls-0.7rc2.jar" main="false" download="eager" size="1453233"/>
           <extension name="MigLayout-3.7" href="MigLayout-3.7.jnlp"/>
           <extension name="SwingWorker-1.2" href="SwingWorker-1.2.jnlp"/>
        </resources>
        <component-desc/>
    </jnlp>Both JARs files in that particular JNLP can be signed with a different certificate from the one of the main jar, same wit the JARs listed in the 2 sub-JNLPs that are referenced here.
    Note: of course, currently, JARs provided by JFXtras are note signed, so I end having to sign them myself anyway, but you get the idea.
    Unfortunately NetBeans does not generate such setup so you'll have to find a tool or develop something that does that for you.
    Perhaps you should try to post your question in the web start forum Java Web Start & JNLP as well but be prepared to face the all knowledgeable and always helpful but not very user-friendly and definitely not patient with new comers Andrew Thompson.
    Note that I've never used external files so I do not know if signing the JAR would fix that particular issue (I do not think so).
    Overall I do not like Java Web Start, as said before, it's cumbersome, time-consuming to use, poorly documented, with basically very little to no packaging/helper tool, prone to failure if you make the slightest mistake in the JNLP(s) definition (having a nebulous documentation of its feature does not help) and they've introduced a stream of bugs and errors with each sub-release of Java 6 for the past year and the half that makes programmer's life a hell and JWS a joke compared to other deployment technologies used by competitors.

  • Jsp:useBean and Tomcat

    Hi!
    I have installed Tomcat as localhost and succeed in running scriplets. But now I want to try using jsp:useBean
    I have compiled a simple class, test1.class and placed it under webapps/root together with the jsp-file.
    When I use �
    <jsp:useBean id="test1" scope="page" class="test1"/>
    to start test1, Tomcat tries to find it in org.apache.jsp
    Then I tried to add - package myFolder; - in test1 but it won�t work.
    So! These are my questions.
    Is it possible for Tomcat to find a class placed in the webapps/root folder?
    Where can I find org/apache/jsp, is it in a .jar-file somewhere? I can�t fint it when I use - search files/folders.
    Where should I place test1.class and how do I write the useBean-tag to make it work?
    Thanks for any answer
    Regards Peter

    your beans should always be under /web-inf/classes
    so if you want to put it in the root directory it should look like this
    tomcat-path/webapps/root/web-inf/classes
    in your jsp file, don't forget to import the bean i.e
    <%@ page import="package_name.mybeans.*" %>
    then use the jsb:useBean the way you did
    <jsp:useBean id="test1" class="test1" scope="page" />
    it should then work fine,
    regards

  • Jsp:useBean no type with name

    On a jsp page, why is it displying:
    no type with this name could be found around
    <jsp:useBean..?
    Could any body help me out?

    Hi Tom
    There is a known limitation with Workshop where you would see those errors when the java classes (the types that error out) are part of you webproject itself.
    The classes get compiled and get moved into web-inf\classes folder and somehow IDE does not get to see this in its classpath.
    The workaround is to move those classes into a java project which will get compiled into a jar file that will be part of libraries (goes into APP-INF\lib).
    You should not see those errors after the workaround.
    This is a known limitation addressed via CR277571
    Thanks
    Vimala

  • Problem with creation of jar with external libraries

    hi guys, I've no problem with creation of jar,i use this command:
    jar -mcf MANIFEST.MF NameFile.jar *.class
    my file manifest is this:
    Manifest-Version: 1.0
    Created-By: Me
    Main-Class: NameFile
    Now,I've to make a jar file,but i have to use some external libraries in jar format.
    I've read on sun tutorial and i've added to manifest this line:
    Class-Path: dt.jar formshelp.jar formsrt.jar jh.jar looks-1.3.1.jar substance.jar TableLayout.jar
    But the jar file doesn't work, neither with a double click nor with console...
    Someone can help me?Thanks!:)

    Darkweb wrote:
    sorry but,the external libraries that i use are in .jar,what i've to do to include these libraries in my jar?One of 3 things
    1) Take them out of the jar, and put them in a folder, preferably a folder in the same folder as the jar
    2) Write a custom classloader to load classes from nested jars
    3) Extract the contents of all the dependency jars, and jar them all up with your own code
    The first is almost always the most preferable, the second one is doable but brittle and resistent to updating dependencies ( you have to release everything for any changes you need, even if it's not a change in your own code ) and the third one is tedious and suffers from the same robustness problems of the second, not to mention that a lot of software licences prohibit you from actually doing it. Do the first one, it's by far the most common and easiest to maintain. I really wouldn't advise the third option, ever, though. Any activity that reduces the modularity of your application is ill-advised

  • Running jsp using Beans (jsp:useBean) on Tomcat 3.2.1 on Linux 7.0

    Hi all,
    In which folder do I keep my java bean class files so that my jsp can use jsp:useBean tag while my jsp's are stored in /webapps/examples/jsp/seet folder.
    Thanks in advance.
    Seetesh

    If their just .class files put them into /webapps/project/WEB-INF/classes
    If they're packaged as a JAR put them into /webapps/project/WEB-INF/lib
    These folders are automatically added to Tomcats classpath.

  • Problem with external libraries and Web DynPro

    Hello,
    we're stuck here.
    We're trying for a week now to include external libraries(e.g. Hibernate) into our Web DynPro Project, without success so far.
    We read every single forum and blog entry we could find on this topic.
    E.g.: /people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro
    We're running Netweaver 2004s SP9 Trial Version.
    The biggest problem is, that when we deploy an J2EE Server Component Library DC exactly like described in the blog entry above, although it is deployed correctly an lists under Server->Libraries in Visual Administrator, the external hibernate.jar doesn't get deployed onto the server. It's just an empty container named hib/lib without any entries in "Jars Contained". The sda file of the library DC also has only 2K and doesn't include the hibernate.jar which we added as used dc...
    Any help would be greatly appreciated.
    Or is there a simpler way to include external jars into Web DynPro Projects and deploy them to the server? (We already tried putting them into the lib folder without luck, we always get "NoClassDefFound...")
    Edited by: Christian Wieland on Jan 31, 2008 11:22 AM

    Hallo Christian,
    this is a bug which should be fixed in NW 7.0 SP9 patch1: [Look at this forum thread on the same issue: External Library DC in NW2004s SP09|External Library DC in NW2004s SP09].
    Regards, Bertram

  • Ant with external libraries and external projects

    I usually use eclipse, now I must use ant for obfuscate my code.
    In eclipse I can import external jars and project. Here is my classpath
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path="src"/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
         <classpathentry combineaccessrules="false" kind="src" path="/PEI"/>
         <classpathentry combineaccessrules="false" kind="src" path="/PEI implementation"/>
         <classpathentry combineaccessrules="false" kind="src" path="/Logger"/>
         <classpathentry kind="lib" path="C:/Java/libraries/jfreechart-1.0.13/jfreechart-1.0.13/lib/jcommon-1.0.16.jar"/>
         <classpathentry kind="lib" path="C:/Java/libraries/jfreechart-1.0.13/jfreechart-1.0.13/lib/jfreechart-1.0.13.jar"/>
         <classpathentry kind="lib" path="C:/Java/libraries/jcalendar-1.3.3/lib/looks-2.0.1.jar"/>
         <classpathentry kind="lib" path="C:/Java/libraries/jcalendar-1.3.3/lib/jcalendar-1.3.3.jar"/>
         <classpathentry kind="lib" path="C:/Java/libraries/mail.jar"/>
         <classpathentry kind="output" path="bin"/>
    </classpath> How can I do the same thing with ant?

    [http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html?PHPSESSID=7292c8206cecdae00f82ea5ac3507e21|http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html?PHPSESSID=7292c8206cecdae00f82ea5ac3507e21]
    [https://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/ant/ant.html|https://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/ant/ant.html].
    [http://ant.apache.org/manual/|http://ant.apache.org/manual/]

  • JSP useBean and Tomcat NoClassDefFoundError

    Hi,
    I have a webapp on tomcat whose structure is like this
    /tomcat
    --/webapps
    ----/mywebappname
    ------/WEB-INF
    --------/classes
    ----------MyBean.java
    When I use useBean class="MyBean" I get a NoClassDefFoundError for this particular class.
    I suspect this is some kind of classpath issue but do not know how to fix it. Help appreciated.

    place u'r class file in <tomcat-root>/classes folder.
    if there's no such folder ,u'll have to create it.

  • Jsp:useBean : Missing value of String classed bean with 'session' scope

    Hi!
    I'd like to ask some help.
    I have these two JSP pages:
    1.jsp<jsp:useBean id="str" class="java.lang.String" scope="session"/>
    <html>
    <body>
    <% str="hello"; %>
    <a href="2.jsp">click</a>
    </body>
    </html>
    2.jsp<jsp:useBean id="str" class="java.lang.String" scope="session"/>
    <html>
    <body>
    <%=str%>
    </body>
    </html>When I open 1.jsp in my browser, then click on the link, the result is "nothing" (empty string). Why does the bean lose its value on the way?
    I use a Tomcat 5.5.9 server.
    Any help will be highly appreciated.

    You have to think of several scopes when working with JSP. The first is the local scope: the method _jspService() where all the work of the JSP is done.  This acts as a normal method and is where all the sciptlet code goes.
    When you use jsp:useBean you are creating two references to a new String object. One in the local scope accessible through <%= str %> and the other in the session scope.
    When you do <% str = "hello"; %> you are changing the local str variable to reference the String "hello" (this is equivalant to doing <% str = new String("hello"); %>). Only the local reference is changed, not the second reference in session.
    If you want the change to take affect, then you will have to store the new value in session with the same name:
    <% session.setAttribute("str", str); %>

  • HT4736 Taking too long (2 minutes) to locate and download photos into Photo '11 9.5 (902.7 build running on an older Intel based MacBook Pro with iPhoto libraries on a USB2 External HD).  I checked and repaired HD permissions. Any ideas?

    Regarding iPhoto '11 9.5 (902.7 build running on an older Intel based MacBook Pro with iPhoto libraries on a USB2 External HD).  I am dealing with iPhoto taking too long to download photos.  Specifically, I rechecked and repaired HD permissions. I am running the most current software my five year old Intel MacBook Pro can run.   What happens is that when I connect an external SD card, or my iPhone, the new version of iPhoto takes up to two full minutes to fully acknowledge the device. Then locate new photos and be ready to download them to my external HD.  I am kind of concerned about this.  This has never happened before. 
    I take 20,000 photos a year.  I really don't want to lose any.  Or is there something I am doing wrong?  Or need to be aware of?  Any experienced suggestions would be appreciated.  Thanks.  Have a great day.
    PS.... The cameras I use are Canon SX-30, Nikon D3100, and my iPhone 4S.  Thanks again for your assistance.

    Hello Old Toad.... Those sound like great ideas. 
    I thought I checked and repaired disk permissions on my main boot HD.  That boot disk is Mac OS Extended (Journaled)  Capacity 749.3 GB.  Available 562.53 GB.   BUT.... now that I think of it.... the Seagate external HD with USB2 interface is: Mac OS Extended (Journaled), Capacity 639.79 GB, Available 36.2 GB with my latest iPhoto Library 517.37 GB that was already scanned & updated to be read by the latest iPhoto version. 
    I'll try your suggestions tonight as far as double checking 'permissions' and setting up a tiny test library.
    Or maybe it's time to fill up another External HD?
    I appreciate your and anyone else's suggestions to try.
    Have a great day. ~~ David in Rochester NY

  • Jsp:useBean gives cannot be resolved to a type in Tomcat

    Hi, I am using Tomcat 5.5
    I have a simple JavaBean for test purposes :
    import java.io.Serializable;
        public class testBean implements Serializable {
            int number;
            public testBean() {
            public int getNumber() {
                return number;
            public void setNumber(int newValue) {
                number = newValue;
        }In a file called testBean.java
    I have successfuly compiled it and put the class file the WEB-INF/classes directory.
    I have the following JSP page :
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <jsp:useBean id="pub" scope="session" class="testBean" />
    <jsp:setProperty name="pub" property="number" value="1" />
    <html>
    <head>
    </head>
    <body>
    <jsp:getProperty name="pub" property="number" />
    </body>
    </html>When I open this jsp page I get the following error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 2 in the jsp file: /test.jsp
    Generated servlet error:
    testBean cannot be resolved to a typeThis example is pretty minimal and I don't understand why it doesn't work. The error seems to be coming from the first JSP statement.
    Any help would be greatly appreciated.
    Thanks in advance.

    1. Put your bean class in a package.
    package test;
    import...........2. Put the .class file in web-inf/classes/test/testBean.class
    3. Specify the fully qualified name of the class in the useBean declaration.
    <jsp:useBean class="test.testBean" .../>Note: You'd be better off following the java bean naming conventions. Specifically your class name should be TestBean (first letter caps).
    ram.

  • Using external libraries with Developer Studio 7.1 Composition Environment

    Hi,
    I downloaded DS 7.1 CE and tried to develop a simple application which uses an external library.
    I created a development component for "external library" for the local development -> MyComponent, giving it the name "test2" (for the domain basis).
    I imported the external library file using Import -> File System , then selecting the .jar file.
    In the component properties browser I added a public part naming it "mylib2" setting the purpose to "ASSEMBLY" (my intention was that the libarry will be transferred during the deployment to the application server).
    I right clicked on the public part to "managed entities". I selected the archive tree and checked the library file shown there (the one I imported before). #
    Then I opended component properties of my web dynpro project and clicked on "Dependencies". The I chose "Add..." and selected the "test2" development component I created before (see above).
    Then I tried to deploy the project (which uses this external library) using "Deploy Archive and Run"
    After deployment the browser window opens and shows the ClassNotFoundException
    So what did I oversee or do wrong?
    BTW: Is it necessary for using external libraries to use a full fletched NWDI? Or can I use external libs also with netweaver development environments freely available for download on sdn.sap.com?
    Any hints?
    Thanks a lot
    Hannes

    Hannes,
    If you want to use external libraries with DCs then you should follow the NWDI completely.
    Check this step, otheways of using external libraries is mentioned <a href="http://help.sap.com/saphelp_nw70/helpdata/en/e3/de813e77d46245e10000000a114084/frameset.htm">here.</a>
    Regards
    Abhilash

  • How to use external libraries and JAR files with OpenScript

    Hello.
    I am trying to include ApachePOI, JODATime, and Javamail in my scripts to handle different aspects of our automated performance tests.
    I followed the documentation for Eclipse to be allowed to utilize these external libraries, however, when I attempt to run my tests the classes and methods that are being imported, show up with errors saying that they do not exist.
    I think perhaps that I am using them incorrectly. I cannot see them as script assets, package assets, or project assets using the properties for these items. An error pops up and says those screens are not displaying correctly or display incorrect information.
    If anyone can provide guidance on using these items, that would be great. Right now I'm trying to include them as "previously exported scripts" but I'm not sure that method will work.
    Any advice is appreciated.
    Thanks.
    --tiff                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Tiff
    For OpenScript 9.* there is an out of the box solution for that, all you need to do in OpenScript go to:
    Script -> Script Properties -> Script Assets -> Add -> jar File ....
    And that is it.
    Alex

  • How use bean of array with tag "jsp:useBean"??

    hi,all
    a bean of array put request with a servlet and forward a jsp page,this jsp use "jsp:useBean" of tag get the bean of array.
    how do for jsp:useBean of tag??
    thx.....

    You can't use an array directly in a jsppage. first u have to write the line <useBean /> through which you can access youtr class
    <jsp:useBean id="email" class="Pack.Email" scope="session" />
    after writing this line you have your class in your hand, you can think of "email" as it is a class object of Email class which is a Bean...
    declare a private array in the Bean and then made method getArray() which will return an array ... then you can use your array in jsp....
    an example of using a class variable in JSp is given below
    public String[] getArray() // note method must be public
    return array;
    now in your jsp page you have to use that class with
    <jsp:useBean id="email" class="Pack.Email" scope="session" />
    and cnow you can use array like this....
    <%
    String[] array=email.getArray();
    for (int i=0; i< array.length;i++ )
    out.println(array]);
    %>
    Does it solve your problem now ?

Maybe you are looking for