Using JARs with JSP?

How do you include JARs in a classpath so that the classes inside can be referred to in <%@ page import="mypackageinajar.myclassinajar" %> ? I've looked through the JSP docs but it only covered import statements. If I can't use a JAR, how would I enable my program to access the class files that I could just manually extract from the JAR?
Thanks

How do you include JARs in a classpath so that the
classes inside can be referred to in <%@ page
import="mypackageinajar.myclassinajar" %> ? I've
looked through the JSP docs but it only covered
import statements. If I can't use a JAR, how would I
enable my program to access the class files that I
could just manually extract from the JAR?You can use JARs, but this is simply a question of how to pack your stuff into a WAR. It has nothing really to do with JSPs...
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/WebComponents3.html

Similar Messages

  • Help me!! How to use JavaScript with JSP ??

    I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
    The page has a ListBox where list items are populated from the database.My requirement is
    whenever the list is changed the page shuold be refreshed with the selected item info.
    I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
    Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
    I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
    I have also gone through the 'readme' but I don't know how to extract .jar file.
    I would be great if you could help me in this.
    Thanks!!
    Geeta
    null

    We have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
    Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
    Do you know of any way to dynamically query the the Oracle database in Javascript

  • Can anyone guide me of using LDAP with JSP?

    I am a beginner in java. Plz post your answers in a simple and easy manner and explain it clearly. I am doing a project for which I require to use LDAP in JSP.

    I assume he wants to use LDAP to authenticate user logon in a JSP application.
    There are a few ways, JNDI being one. But a simpler method might be to see if this library works for you:
    http://www.mozilla.org/directory/javasdk.html
    HTH.

  • How to use SOAP with JSP (New to SOAP)

    Hi,
    i had a sch assignment(a set of JSPs)............anyone know how i can go about using soap for the encoding of data ? cos i had read up some books but i'm not sure how to go about implementing it !!!!! Anyone can help me?
    Regards,
    khim

    Hey,
    Just trying to understand the assignment objective:
    You have a SOAP message or some web-service that replies with SOAP messages?
    You have been asked to write a JSP that (queries this web-service and) retrieves the SOAP encoded data and transform it into XHTML (by whatever method you want) using XSLT?
    Is this the situation?
    If it is you will need to get the DTD or XSD of the SOAP message you will be displaying. This will tell you what elements to expect, what attributes they have and their sequencing.
    Then your problem is just the XSL style sheet. Here is a link if you do not kow much about XSL:
    http://www.w3schools.com/xsl/default.asp
    To perform the transform you can either use JSTL tags or you can use a Bean... I would suggest the JSTL tags.
    I hope the advice is not too late.
    Warm regards,
    Darren

  • Using JavaBean with JSP...will not work no matter what

    Hi guys. Sorry that this is such a common, newb question, but I don't know where else to turn.
    I'm new to web application development, Tomcat, and JSP. I'm trying to use a simple JavaBean in a JSP to store some user information. The JSP is located in $CATALINA_HOME\webapps\art , and the UserBean I'm trying to use is in $CATALINA_HOME\webapps\art\WEB-INF\classes . I've tried adding a context in the Tomcat server.xml file, but nothing seems to work, even putting the .class file into the \art directory along with the JSP. The error I get is the following:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 1 in the jsp file: /welcome.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\art\welcome_jsp.java:43: cannot resolve symbol
    symbol : class UserBean
    location: class org.apache.jsp.welcome_jsp
    UserBean user = null;
    ^
    The source code is:
    welcome.jsp
    <%@ page import="java.sql.*" %>
    <jsp:useBean id="user" class="UserBean" scope="session"/>
    <html>
    <head>
    <title>Art Webapp Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <h1>Art Site</h1><br><br>
    <h3>Welcome Page</h3><br><br>
    <%
         user.setUsername("joe");
    user.setTitle("admin");
    %>
    </body>
    </html>
    UserBean:
    public class UserBean {
    private String username = null;
    private String title = null;
    public UserBean()
         this.username = null;
         this.title = null;
    public String getUsername()
         return this.username;
    public String getTitle()
         return this.title;
    public void setUsername(String inName)
         this.username = inName;     
    public void setTitle(String inTitle)
         this.title = inTitle;     
    }//UserBean
    Thanks for any and all help anyone could give me about this. It seems such a simple thing, to get a JavaBean working in a JSP...and it's very frustrating to have it NOT work when it seems I've done everything possible to get it to.

    Ok, I figured out what the problem was. My Bean was not a part of any specific package. It was never made clear to me that Beans are required to be a part of some package...I had no idea (though they always put them in packages in the tutorials, you think I would have picked up on it!).
    So I just added the following line to the Bean:
    package com.art;
    Then compiled it and copied the .class file to CATALINA_HOME\webapps\art\WEB-INF\classes\com\art
    Ta-da
    Thanks for the help and sorry for taking up space on this board.
    -Matt

  • Using DLL  with JSP

    I have a dll component writing with C++.
    I want to use this DLL in a JSP Pages.
    Is it possible?
    How could i do?
    I don't want to use JNI because I don't know JAVA.
    thanks.
    Bye.

    I have a dll component writing with C++.
    I want to use this DLL in a JSP Pages.
    Is it possible?Yes.
    How could i do?With JNI.
    I don't want to use JNI because I don't know JAVA.Then you are screwed. Maybe you should use ASP.

  • Problem when using JDBC with JSP

    Hi,
    I am trying to display results after a database query on a JSP page, and then provide the options delete or update one of these records or to add a new one.
    What I did was to pass the ResultSet object to the webpage, and then display the result. When the buttons are pressed, I pass this ResultSet to another jsp page where I provide the required functionality. This is then forwarded back to the previous JSP, where the new data is displayed.
    However, when the first page is re-displayed, it creates a new connection and i was wondering if there is a way to close the previous connection through the ResultSet?
    Also, I wanted to put the ResultSet in a bean, but I think it is causing an error in the web server, saying something like it is not Serializable. Is there any other way to pass the ResultSet around?
    Any suggestions on better ways to manage databases though web interfaces would be welcome, or if someone could point me to a good tutorial on this topic!
    cheers
    Ankur

    Bad idea to be passing ResultSets around. Those are database cursors, a scarce resource.
    You should load that data into a data structure, close the ResultSet immediately, and then pass the data structure around in session if you must.
    Better yet, have a central servlet that deals with all database calls. Let the JSPs just do display, as they were meant to. - MOD

  • I want to use nl2br with JSP

    Hi, I wouldlike to know how use this method
    nl2br(java.lang.string)
    I write it in my code :
    String texte=nl2br(ProdServ);
    and the serveur error is :
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\Site_changement\ModifEnt$jsp.java:139: Method nl2br(java.lang.String) not found in class org.apache.jsp.ModifEnt$jsp.
    String texte=nl2br(ProdServ);
    ^
    can someone help me please
    Thank you

    I dont realy understand what i must import...the class is Object but it' write under :
    java.lang.Object
    |
    --com.generationjava.web.HtmlW
    what i have to import? Do I have to import it in my page only?
    Thank you

  • Using JDBC with JSP

    I have a standalone application using Swing. Im converting it to a web / JSP/Servlets application.
    Can my JSP acess my database using the same classes it used to or should I configure in my Tomcat a data source and call my database using the jndi name ?
    thx in advance,
    Giselle

    Agreed - JSPs are best for presentation.
    I have a front controller servlet that delegates to POJOs to do database interactions and then forwards results to JSPs for display. No scriptlet code in my pages, no database interactions, just looping through collections and displaying the results. - MOD

  • Using jFreeCharts with JSP-Servlet Web App

    Can someone please help me to get started on using the jFreeCharts in mt JSP Servlet we app? So far I have this in my servlet but I do not know what to do from here.
    protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
    //          create a dataset...
              double[][] data = new double[][] {
              { 1.0, 4.0, 3.0, 5.0, 5.0, 7.0, 7.0, 8.0 },
              { 5.0, 7.0, 6.0, 8.0, 4.0, 4.0, 2.0, 1.0 },
              { 4.0, 3.0, 2.0, 3.0, 6.0, 3.0, 4.0, 3.0 }
              //DefaultCategoryDataset dataset = new DefaultCategoryDataset(data);
              //return DatasetUtilities.createCategoryDataset("Series ", "Factor ", data);
              CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Factor ", data);
              JFreeChart chart = ChartFactory.createBarChart(
         "Bar Chart Demo 2", // chart title
         "Category", // domain axis label
         "Score (%)", // range axis label
         dataset, // data
         PlotOrientation.HORIZONTAL, // orientation
         true, // include legend
         true,
         false
         }

    the JFreeChart documentation has examples doing just that.
    And if you don't know how to get a browser to call some resource from some html you should get a beginner's tutorial to html.

  • Using beans with jsp

    Hi
    i am using tomcat 6.0 and jdk 1.6u17
    i am trying to use a bean to connect to MySql db using jsp page but i keep getting the error :
    org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
    i read about it and i think that it is unable to locate my bean class file
    here is the beanDb.java
    package beans;
    import java.sql.;
    import java.io.;
    public class beanDb
    private Connection dbCon;
    String path="jdbc:mysql://localhost:3306/dbname?user=username&password=pwd";
    String dbDriver="com.mysql.jdbc.Driver";
    public beanDb()
    super();
    public boolean connect() throws ClassNotFoundException,SQLException
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection(path);
    return true;
    public void close() throws SQLException
    dbCon.close();
    public void path()
    public ResultSet execSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
    public int updateSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    and the jsptest.jsp code is :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <jsp:useBean id="beanDb" class="beanDb" scope="request" />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <%
    out.println(beanDb.connect());
    %>
    </body>
    </html>
    the location of these files are :
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\WEB-INF\classes\beans\beanDb.java
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\jsptest.jsp
    Please suggest a solution..
    Thanks

    http://forums.sun.com/thread.jspa?threadID=5423314

  • Using beans with jsp without any ide

    Hi
    i am using tomcat 6.0 and jdk 1.6u17
    i am trying to use a bean to connect to MySql db using jsp page but i keep getting the error :
    org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
    i read about it and i think that it is unable to locate my bean class file
    here is the beanDb.java
    package beans;
    import java.sql.*;
    import java.io.*;
    public class beanDb
         private Connection dbCon;
         String path="jdbc:mysql://localhost:3306/dbname?user=username&password=pwd";
         String dbDriver="com.mysql.jdbc.Driver";
         public beanDb()
              super();
         public boolean connect() throws ClassNotFoundException,SQLException
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection(path);
    return true;
         public void close() throws SQLException
         dbCon.close();
         public void path()
         public ResultSet execSQL(String sql) throws SQLException
              Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
         public int updateSQL(String sql) throws SQLException
         Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    and the jsptest.jsp code is :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <jsp:useBean id="beanDb" class="beanDb" scope="request" />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <%
                   out.println(beanDb.connect());
                   Connection connection;
                   Statement stmt = null;
                   ResultSet rs = null;
    %>
    </body>
    </html>
    the location of these files are :
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\myApp\WEB-INF\classes\beans\beanDb.java
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\myApp\jsptest.jsp
    Please suggest a solution..
    Thanks

    here is the changed code but still the same error:
    package beans;
    import java.sql.;
    import java.io.;
    public class beanDb
    private Connection dbCon;
    String path="jdbc:mysql://localhost:3306/dbname?user=username&password=pwd";
    String dbDriver="com.mysql.jdbc.Driver";
    public beanDb()
    super();
    public boolean connect() throws ClassNotFoundException,SQLException
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection(path);
    return true;
    public void close() throws SQLException
    dbCon.close();
    public void path()
    public ResultSet execSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
    public int updateSQL(String sql) throws SQLException
    Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    and the jsptest.jsp code is :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <jsp:useBean id="beanDb" class="beanDb" scope="request" />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    <%
    out.println(beanDb.connect());
    %>
    </body>
    </html>
    the location of these files are :
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\WEB-INF\classes\beans\beanDb.java
    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\myApp\jsptest.jsp

  • Flush=true, Should i be using this with jsp:forward...

    I had read up on this flush=true. SHould i be using it. Does it cause memory leaks with out it. I have read many articles and im confused. Can anyone explain this to me.
    Thanks

    anyone have any ideas on this. I have read through most of the forums and I am still unclear,
    Thanks again

  • RE: Using JavaMail with JSP when access relay is denied on smtp mail server

    Could someone please let me know how to get around the problem of sending an automatic email from a JSP when access relay is denied by the smtp mail server. Could it be that the username and password just needs to be added somewhere???
    Any thoughts on how to solve this problem would be greatly appreciated.
    Thank you!

    I know what you are talking about because I setup no relay on my mail server. I understand why you need to supply a username and password because if the server doesn't allow relay, then you must supply a username and password. Doing it by IP address wouldn't work because you have to know the IP address of all people accessing that page. I am in the same boat as you and once I find out the answer, you'll be the first to know. There is one quick workaround. Get your Net Admin to create a user specifically for the page you plan to send from. Get him to allow relaying for that one user. That worked on my setup and like I said, I'm setup the same way you are. Thanks, J

  • Use of Threads with JSP's

    Can you use threads in a web application that uses JSP's plus Servlets and Beans ?
    We have a JRUN 3.1 application using JSPs, Servlets and Beans. Shortly after we went live it became apparent that any 2 users using the same object experienced problems as one object was overwriting another. In a panic the problem was solved by whacking SYNCHRONISED on all objects.
    Now we want to write another application, are there strategies for using Threads with JSPs?
    Would this be part of the webserver configuration or would the application be coded in a certain way ?
    Please can you give me a simplistic answer or point me to some documentation that gives a simple overview.
    Thanks Steve

    Hi,
    You can use thread with jsp, i am sending u a example
    package thread;
    import java.io.Serializable;
    public class TaskBean implements Runnable, Serializable {
    private int counter;
    private int sum;
    private boolean started;
    private boolean running;
    private int sleep;
    public TaskBean() {
    counter = 0;
    sum = 0;
    started = false;
    running = false;
    sleep = 100;
    protected void work() {
    try {
    Thread.sleep(sleep);
    counter++;
    sum += counter;
    } catch (InterruptedException e) {
    setRunning(false);
    public synchronized int getPercent() {
    return counter;
    public synchronized boolean isStarted() {
    return started;
    public synchronized boolean isCompleted() {
    return counter == 100;
    public synchronized boolean isRunning() {
    return running;
    public synchronized void setRunning(boolean running) {
    this.running = running;
    if (running)
    started = true;
    public synchronized Object getResult() {
    if (isCompleted())
    return new Integer(sum);
    else
    return null;
    public void run() {
    try {
    setRunning(true);
    while (isRunning() && !isCompleted())
    work();
    } finally {
    setRunning(false);
    And JSP page start.jsp
    <% session.removeAttribute("task"); %>
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(true); %>
    <% new Thread(task).start(); %>
    <jsp:forward page="status.jsp"/>
    ///////////////// status .jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <HTML>
    <HEAD>
    <TITLE>JSP Progress Bar</TITLE>
    <% if (task.isRunning()) { %>
    <SCRIPT LANGUAGE="JavaScript">
    setTimeout("location='status.jsp'", 1000);
    </SCRIPT>
    <% } %>
    </HEAD>
    <BODY>
    <H1 ALIGN="CENTER">JSP Progress Bar</H1>
    <H2 ALIGN="CENTER">
    Result: <%= task.getResult() %><BR>
    <% int percent = task.getPercent(); %>
    <%= percent %>%
    </H2>
    <TABLE WIDTH="60%" ALIGN="CENTER"
    BORDER=1 CELLPADDING=0 CELLSPACING=2>
    <TR>
    <% for (int i = 10; i <= percent; i += 10) { %>
    <TD WIDTH="10%" BGCOLOR="#000080"> </TD>
    <% } %>
    <% for (int i = 100; i > percent; i -= 10) { %>
    <TD WIDTH="10%"> </TD>
    <% } %>
    </TR>
    </TABLE>
    <TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
    <TR>
    <TD ALIGN="CENTER">
    <% if (task.isRunning()) { %>
    Running
    <% } else { %>
    <% if (task.isCompleted()) { %>
    Completed
    <% } else if (!task.isStarted()) { %>
    Not Started
    <% } else { %>
    Stopped
    <% } %>
    <% } %>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER">
    <BR>
    <% if (task.isRunning()) { %>
    <FORM METHOD="GET" ACTION="stop.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Stop">
    </FORM>
    <% } else { %>
    <FORM METHOD="GET" ACTION="start.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Start">
    </FORM>
    <% } %>
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    ////////////////////////////// stop.jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(false); %>
    <jsp:forward page="status.jsp"/>
    deploy it into ur server and run start.jsp
    and see whatb happens

Maybe you are looking for

  • Problem with sound capture on a Packard Bell

    Hello, recently I have acquired a Packard Bell EASYNOTE MX61-B-054PT notebook to replace my dead Asus. Everything is working quite well except for sound capture from the microphone. There is a periodic noise that I can't get rid of (the noise I'm tal

  • Chinese Character Sets

    I'm setting up a web site, as a favor for a friend, that will be in Chinese and French. I'm not sure what the best page encoding would be. My friend sent me some sample Chinese, and she said, "The font I use is 'Simsun'." Otherwise, she is not very t

  • Server crash caused by "Potential VM growth in DirectoryService"

    Our mail server experienced a crash yesterday. The system log reports "Potential VM growth in DirectoryService...". The Intel Xserve is fully patched to 10.5.5 and no updates are available. This is the first time we have experienced this problem. Fro

  • New business configuration with DBM action control

    Hi, We want to update certain additional information for order and split after billing. DBM blocks data updation in DBM order after billing creation and order close. How we can achieve same? Regards, Bobby

  • How to package my files

    I have Adobe Illustrator CS6. How do I package my files? I read that this should be under File > Package. I don't see this listed on my software. thanks, Breanna