Accessing MyClass in a JSP?

I have some classes that I've put in a jar file, samp.jar
Where should I put this jar file if I should be able to use the classes in it? I have not packaged the classes...
I just have them archived in samp.jar
Also, where is a packaged class to be put and how should it be accessed in a JSP?
I am very lost!! please help...
thanks in advance,
sangita

You have to provide all your code (JSP and classes) inside of a so called web application. This has a certain structure on which the servlet container relies. There are two possiblities to build a web application: a war (web application archive) file or a directory containing the unpacked structure of a war file.
The structure looks like that:
/. files which can be accessed via browser (e.g.JSPs)
/WEB-INF/web.xml your web application descriptor (see example of your servlet container)
/WEB-INF/lib/ put jar files here which contain servlets or you want to access from servlets
/WEB-INF/classes same as lib but unpacked class files                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to access java method in JSP

    Hi all,
    I need to access java class (abstract portal component) method doContent() in a JSP which is under PORTAL-INF/jsp folder.
    I did
    <%@ page import = "com.mycompany.Aclass" %>
    <%com.mycompany.Aclass a = new com.mycompany.Aclass (); %>
    Aclass is coming as autofill/prepopulated with cntrl+space
    Till this time, it is working. no errors. But when I do
    a.
    a. (a dot) no methods are populating (autofill..cntrl+space) or If I forcebly add method a.doContent(req,res)... at runtime its giving error.
    It's not only with doContent method... Its with any simple methods in that class or any other class.
    (Other than doContent method in the APC java class are prepopulating/autofilling but giving error in runtime)
    Can anyone help me... how to access java method in JSP.
    I already gone through many SDN forum post... and implemented too---but no use I refered below forum thread
    Retrieve values from Java class to JSP
    URGENT! How to call a java class from JSP.
    Calling a java method from jsp file -
    this thread is same as my issue
    Thanks,
    PradeeP

    1st. The classes must be in packages. 2nd, the package that they are in must be under the WEB-INF/classes directory. 3rd Look on google and/or this site for web application deployment

  • Urgent-how to access custom tag from jsp tag

    I have a problem accessing a custom tag from a jsp expression.
    Details: I have a custom tag that returns a string variable. I need to access that variable from jsp expression <%%>.
    Can any body help me?

    Tags don't "return" values as in the normal sense.
    They can only support TEI (Tag Extra Information) that just stuffs a declared variable into the page's state.
    For example, if the tag class had a public method called getValue(), you could do the following:
    <xmp:mytag id="foo"/>
    <%
    out.println("value is " + foo.getValue());
    %>

  • Message bundles accessed from JSF and JSP pages

    Hello, everybody!
    I'm developing a localized JSF application. It is working pretty well until now.
    These are my message files:
    mensagens.properties
    mensagens_en_US.propertiesThis is how they're configured in faces-config.xml:
    <application>
        <resource-bundle>
            <base-name>br.urca.www.biblioteca.web.mensagens</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>And this is how I access the messages in a page:
    <h:outputText value="#{msg.titulo}" />Nothing new until now. But now there was a need for me to have a raw jsp page in
    my web application. This page is displaying ok but I also need to access the
    message bundles as I'm able to access in the normal jsp with the JSF components.
    As you should know I can't use something like the above code with an +<h:outputText>+
    to access the messages because this is a JSF component and I'll not be able to use
    JSF components with this raw jsp page.
    So, my question is: how do I access my localized messages from a raw jsp page? I
    suppose there should be a way to do this, but unfortunately I started programming
    to the web world in Java with JSF, not JSP, so I don't know how to do this with
    JSP.
    Thank you very much.
    Marcos

    BalusC wrote:
    Just include [jstl-1.2.jar|https://maven-repository.dev.java.net/repository/jstl/jars/] in your classpath and define the fmt taglib in your JSP. Nothing more is needed.
    Hello, BalusC. Thank you for your help. We're almost there. After I have included the jstl-1.2.jar you provided me I can use the fmt tag and access message bundles from my raw jsp page (even though I had to provide other message bundles instead of the ones that I use in the other jsf pages, but it's better than nothing).
    Now there just on problem to be fixed. The jsp page is not aware when I change the locale of my application. I change this locale in a jsf page.
    I have this component:
    <h:selectOneMenu value="#{pesquisaAcervo.idiomaAplicacao}"
        valueChangeListener="# {pesquisaAcervo.idiomaAplicacaoMudado}" onchange="submit();">
        <f:selectItems value="#{pesquisaAcervo.idiomasAplicacao}" />
    </h:selectOneMenu>that calls this event in my backing bean class:
    public void idiomaAplicacaoMudado(ValueChangeEvent e)
        fIdiomaAplicacao.liberarItens();
        Idioma idioma = Idioma.deString(e.getNewValue().toString());
        // This line is for JSF
        FacesContext.getCurrentInstance().getViewRoot().setLocale(idioma.localidade());
        // This line is for Tiles
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().
            put(org.apache.tiles.locale.impl.DefaultLocaleResolver.LOCALE_KEY, idioma.localidade());
    }So, do I have to include another line in the idiomaAplicacaoMudado event above in order for the jsp page load the correct resource bundle? Or what else do I have to do?
    Thank you.
    Marcos

  • Problem with accessing init parameters from JSP file

    Hi,
    I have my init parameters and Jsp configured in web.xml
    <servlet>
              <servlet-name>TestJsp</servlet-name>
              <jsp-file>/Test.jsp</jsp-file>
              <init-param>
                   <param-name>username</param-name>
                   <param-value>Balboa</param-value>
              </init-param>
    </servlet> How do I access 'username' field from JSP file.
    Kindly help.
    Thanks.

    you can do this in the jsp
    <%=config.getInitParameter("username")%>or do it in the jspInit method in the jsp:
    <%!  String userName = null; 
      public void jspInit() {   
        ServletConfig config = getServletConfig();   
        userName   = config.getInitParameter("userName ");  
    %>
    Hello <%=userName%>

  • Accessing MySql database in jsp

    hi everyone!!!
    i m new to java with little knowledge of jsp.
    i want to access mysql database in jsp to develop a web page.
    i have jdk and mysql installed and these are working. what are other requirements and how to do this.
    plz help.
    OS: MS Windows XP/ Fedora 10

    Learn JDBC API: [http://java.sun.com/docs/books/tutorial/jdbc/index.html]. Create a DAO class which uses JDBC to interact with Java and takes or returns the desired data in form of DTO's. Use and test it as a plain vanilla Java application with a main() method. This require a JDBC driver (a concrete implementation of the JDBC API) in the classpath. MySQL offers JDBC drivers as download at their homepage, it is called "Connector/J".
    Once you got the JDBC part to work, create a Servlet class which holds an instance of the DAO class and uses its methods to interact with the database. In the doGet() you can place logic to preload data from the DAO class for display. In the doPost() you can place logic to process data for create, update or delete using the DAO class. Finally let it forward the request to a JSP.
    In the JSP you can use JSTL/EL to display data. For tabular view you may find the JSTL c:forEach useful. For plain display, just use EL the usual way.

  • How to create a sling:OsgiConfig property and access it in component Jsp ?

    How to create a sling:OsgiConfig property and access it in component Jsp ?
    I have created a OSGI config property under apps/<Project>/config and it is reflected on OSGI console but I am not able to access ie in component jsp.
    Any pointers are appreciated

    Use this code in the scriplet in your required components jsp:
    <%@page import="org.osgi.service.cm.ConfigurationAdmin"%>
    <%@page import="org.osgi.service.cm.Configuration"%>
    <%
    Configuration conf = sling.getService(org.osgi.service.cm.ConfigurationAdmin.class).getConfiguration("Name of the config");
    String myProp = (String) conf.getProperties().get("property key");
    %>

  • How to access COM+ Objects From JSP

    Friends,
    We have a requirement to access COM+ objects from JSP. Please guide me on this.
    Thanks in advance.
    Tarani

    Sanyam wrote:
    if there is any .dll extension file, how can we read that file in labview?
    You can use Call Library Function node to call that dll file and use it in LabVIEW. Read the help and you will get more details.

  • JAVA API of Oracle BPEL, to access the "Task Form"(JSP) of a human task.

    Hi,
    Are there any JAVA API of Oracle BPEL, to access the "Task Form"(JSP) of a human task, to render the task form inside the custom worklist application.
    Thanks,
    Naga

    I guess you mean accessing the task details and the payload from the java API.
    Refer the below blog it will provide you the details
    http://www.albinsblog.com/2012/05/update-human-task-payload-via-java-api.html
    Regards
    Albin I
    Edited by: Albin on Sep 19, 2012 11:24 PM

  • Accessing another par file jsp pages

    Hi
    i need to access another par file JSP pages from my par file, what all i need.
    any help is appreciated.
    Thanks,
    Damodhar.

    Gandhi,
    Well..there is a very good article on how to use resources(watever resources u mentioned) of one par inside any other par file on SDN:
    Here is the document:<a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b3c1af90-0201-0010-c0ac-c8d802d264f0">JSPs, Resources...</a>
    Xml files i worked were not property files of an iview.
    They were application specific xml files.I read these xml files on a different par(or iview).For that matter, they don need not be of type xml,could be any type of resource.
    Regards,
    P.

  • Error due to accessing database connection using jsp

    Hi,
    I have an error, during accessing a datbase using jsp:useBean from jsp.Urgent i need this one
    my source code is
    DbBean.java
    package SQLBean;
    import java.sql.*;
    import java.io.*;
    public class DbBean implements java.io.Serializable{
    private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
    private Connection dbCon;
    public DbBean(){
    super();
    public boolean connect() throws ClassNotFoundException,SQLException{
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
    return true;
    public void close() throws SQLException{
    dbCon.close();
    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;
    database.jsp
    <HTML>
    <HEAD><TITLE>DataBase Search</TITLE></HEAD>
    <BODY>
    <%@ page language="Java" import="java.sql.*" %>
    <jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />
    <jsp:setProperty name="db" property="*" />
    <center>
    <h2> Results from </h2>
    <hr>
    <br><br>
    <table>
    <%
    db.connect();
    ResultSet rs = db.execSQL("select * from employ");
    int i = db.updateSQL("UPDATE employ set fname = 'hello world' where empno='000010'");
    out.println(i);
    %>
    <%
    while(rs.next()) {
    %>
    <%= rs.getString("empno") %>
    <BR>
    <%
    %>
    <BR>
    <%
    db.close();
    %>
    Done
    </table>
    </body>
    </HTML>
    The error like this
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    error: Invalid class file format in C:\Program Files\Apache Tomcat 4.0\webapps\muthu\WEB-INF\classes\SQLBean\DbBean.class. The major.minor version '49.0' is too recent for this tool to understand.
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:65: Class SQLBean.DbBean not found.
    SQLBean.DbBean db = null;
    ^
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:68: Class SQLBean.DbBean not found.
    db= (SQLBean.DbBean)
    ^
    An error occurred at line: 7 in the jsp file: /database.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:73: Class SQLBean.DbBean not found.
    db = (SQLBean.DbBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "SQLBean.DbBean");
    ^
    4 errors, 1 warning
    Anybody help me?
    Thanx in advance

    Your code is ok . The problem is in java version witch you use to compile the DbBean class . I think you are using java 1.5 try to change to 1.4 compile and run again should help .

  • How to access class members in jsp??

    i m working in jsp and i make a class Student having attribute name and id and i store it at tomcat\classes\Student.java
    and i store a jsp page at tomcat\webapps\root\student\index.jsp
    now i create object of class Student in jsp page it works
    but when i try to access name(Student.name) or id(Student.id)(or any class member of Student class)it shows error message
    now pls tell me how can i access class members in jsp page.

    i m working in jsp and i make a class Student having attribute name and id and i store it at tomcat\classes\mypack\Student.java
    and i store a jsp page at tomcat\webapps\root\student\index.jsp
    now i create object of class Student in jsp page it works
    but when i try to access name(Student.name) or id(Student.id)(or any class member of Student class)it shows error message
    now pls tell me how can i access class members in jsp page.
    Note: class members r public.

  • Setup mySQL and access the same from jsp

    Hi,
    I have installed the MySQL in local desktop in d: drive. As per the documentation, have created my.cnf file to point sql directory in d drive.
    Now I dont know how to proceed further. I need to see if MySQL installation is fine, create table and access the data in jsp page. Please advice.
    Thanks in advance.

    For MySQL help try a MySQL forum.
    For connecting to the database, use JDBC. You can get the MySQL JDBC driver from www.mysql.com.
    From there just follow standard java database connection setup.
    http://java.sun.com/docs/books/tutorial/jdbc/index.html

  • Java class bean can not access to DB in JSP file

    Hi, I wrote a java class bean in order to access to MySql database ,and this bean is used in a JSP file,so that the bean can query from DB and then display the queried information on the JSP file,but it can not work correctly,the following is the source code and error message popup by the system,
    does anybody has experience in solving thus question,Please reply ,Thank you for your help.
    %@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ page import = "java.sql.*" %>
    <jsp:useBean id="conn" scope="page" class="news.conn"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>1</title>
    <style>
    <!--
    A:link {
         COLOR: #993399
    .s {
         FONT-SIZE: 13px; LINE-HEIGHT: 170%; FONT-FAMILY: "utf-8"
    -->
    </style>
    </head>
    <body>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
    <tr>
    <td width="100%">
    <img border="0" src="images/ruanjian.jpg" width="770" height="154"></td>
    </tr>
    <tr>
    <td width="100%">@</td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
    <tr>
    <td width="13%">@</td>
    <td width="87%">
    <img border="0" src="images/mid-rdxw2.gif" width="101" height="18"><p>
    <%
              ResultSet rs,rsNest;
    String strSql=null;
    strSql = "select * from news where TYPE=1";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt(id")%">"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>
    <img border="0" src="images/mid-hyxw2.gif" width="94" height="19"></p>
    <%
    strSql="select * from news where TYPE=2";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt("id")%>"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>@</td>
    </tr>
    </table>
    <p align="center">Study Online</p>
    <p align="center">@</p>
    </body>
    </html>
    Error message:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Exception in JSP: /newsMain.jsp:47
    44: strSql = "select * from news where TYPE=1";     
    45:           rs = conn.executeQuery(strSql);
    46:           
    47:           while (rs.next()){
    48:
    49: %>
    50:
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    root cause
    java.lang.NullPointerException
         org.apache.jsp.newsMain_jsp._jspService(newsMain_jsp.java:98)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 l</a>

    nogoodatcoding wrote:
    Tolls wrote:
    Is that Jasper Exception telling us where the problem is in the jsp, though?
    If it is, then "rs" is null in the call rs.next()...which means conn.executeQuery() is returning null. Which means that whatever class conn is (news.conn?) has a problem maybe?That's possible. Though, it may just be the case that the 'conn' object itself is null! That line is the first place where it's being used and there are no checks that I can see...we'll have to wait for the OP to investigate and reply I guess.That's what I originally thought, then I noticed it was saying line 47, which is the rs.next() line. Assuming Jasper is correct in its choice of line, then it's the rs that's null. Which means the conn is doing strange things.
    Edit: Now that I think about it, going by the previous thread the OP posted, I'm wondering whether news.conn class is their attempt to move the JDBC stuff out of the JSP page, and it's grabbing the "real" connection (java.sql.Connection) and getting the result set and returning it...or getting something wrong and returning null.
    Edited by: Tolls on 11-Jun-2009 12:24

  • Accessing JSTL values from JSP

    I've run into a problem I'm not sure has a solution. Could be bad design on my part, or just a poor imagination. If this has been answered previously, please point me to the post.
    I am using some JSTL to do a SQL query and displaying the records in a select box:
    <sql:query var="aResults" sql="select * from TYPE_STATE_LIST where tslAllowable=1" />                           
    <c:forEach var="oRecord" items="${aResults.rows}">                               
      <option value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option>                                   
    </c:forEach>I want to be able to reset their selection to the value they entered when the form is refreshed, though. I'm trying to figure out how to grab the oRecord value from the JSTL and use it in a JSP IF statement:
    <% if( oRecord.tslID==request.getParameter("state") ) { %>
      <option selected value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option> 
    <% } else { %>
      <option value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option> 
    <% } %>I thought about using the JSTL <c:choose> tag instead, but then how would I access the previous value with request.getParameter()?
    Any suggestions?

    ${param.state}It's better if you place the sql query into a class rather than display it in the jsp, it's more flexible and programmable.

Maybe you are looking for

  • Vendor in customer master

    Hi friends, this is shyam can you tell me what is the relevance of vendor tab in customer master and which scenario you use this regards shyam

  • How to set the screen size with nested Iview screen

    Can someone show me how to set the screen size with nested IView  screen. at the moment i only try it with trial and error untill it looks somewhat close. Is there a property in VC to set the size for Height and width. The same question is for the fo

  • Setting Search Directory with LabVIEW RTE

    Hi, I've LabVIEW 8.0.1 run time engine installed on target computer and would like to run LabVIEW executable on target computer.  I also have required low level support VIs for developed VIs.  Question is: how do I set the search directory for low le

  • Custom screen saver idle time

    Is there a way to set a custom screen saver idle time? Through terminal? I tried "defaults -currentHost write com.apple.screensaver idleTime 160" for 3 minutes but that makes it go to 20 when I view it in preferences... lol, wow. This is hilarious. I

  • Cprojects RPM bapi_bus2175_get_detail

    Hi Guys , When i run the bapi_bus2175_get_detail  i do not get any results populated in e_roleassingment table. i get the values in authorizations table. The actual finish date is also returned in odd formate. i am trying to get the users that can be