Creation of a context listener in a web project

Hello.
We need to create a custom context within a web application.
In other projects what we do is create an implementation of the class javax.servlet.ServletContextListener, and reference it as a listener in the web.xml. This alows us to create threads within the container of the server, for instance.
The problem is that after I create the web project in my developer studio 7.2 the class javax.servlet.ServletContextListener is not found within the classpath, that is referencing a Java CE 7.2 server.
The project I created received the SAP Java EE 5 Library, but the class is not present in that.
Is there another library from SAP I need to add? If I import that class from another jar, will it be well supported by the server?
Thanks!

I found the solution, that was only related to problems on my classpth. Thanks!

Similar Messages

  • How to set up context parameter of a web application

    Hi,
    I am tring to deploy a ear file to J2EE Engine 7.1
    with the help of import feature of NWDS.
    Is there any option to set the value of the context parameters defined in web.xml inside the ear.
    Regards,
    Chitra

    Thanks for your response.
    Th e version no. of IE Tab is 4.0.20130422 and it is from https://addons.mozilla.org/en-US/firefox/addon/ie-tab/
    Look forward your reply.Thank you in advance.

  • How can I get the context-parm from a web.xml file using struts?

    Hello:
    I need get the context-param from the web.xml file of my web project using struts. I want configurate the jdbc datasource connection pooling here. For example:
    <context-param>
    <param-name>datasource</param-name>
    <param-value>jdbc/formacion</param-value>
    <description>Jdbc datasource</description>
    </context-param>
    and then from any Action class get this parameter.
    Similar using a simple server can be:
    /** Initiates new XServlet */
    public void init(ServletConfig config) throws ServletException {
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();) {
                   System.out.println(e.nextElement());
              super.init(config);
              String str = config.getInitParameter("datasource");
              System.out.println(str);
         public void doPost(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              // res.setContentType( );
              System.out.println("Got post request in XServlet");
              PrintWriter out = res.getWriter();
              out.println("nada");
              out.flush();
              out.close();
    but only this works for init-params, if I use
    <servlet>
         <servlet-name>MyServlet</servlet-name>
         <display-name>MyServlet</display-name>
         <servlet-class>myExamples.servlet.MyServlet</servlet-class>
         <init-param>
         <param-name>datasource</param-name>
         <param-value>jdbc/formacion</param-value>
    </init-param>
    </servlet>
    inside my web.xml. I need something similar, but using struts inside the action class for that I can get the context-params and call my database.
    Thank you

    To get context parameters from your web.xml file you can simply get the ActionServlet object from an implementing action object class. In the perform (or execute) method make the following call.
    ServletContext context = getServlet().getServletContext();
    String tempContextVar =
    context.getInitParameter("<your context param >");

  • How to Enhance the Context menu in a Web Report

    Gurus,
    Scenario is to Enhance the Context menu in a Web template with some Custom Values. I found some notes in SAP.HELP but could not get thru it.
    If anyone has added some Custom developed menu's in the Context menu, can you let me know as well.
    Urgent help would be appreciated as well as rewarded with marks.
    Regards
    Rohit

    Hi Rohit,
    I have done this for solution manager with bex integration,
    Go TO last part of pdf there it is discussed with screen shot.You need to hav a query go to web template.and use the html tags to insert something into your context menu.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ad0a4b07-0301-0010-5095-ef7615676fc0
    Please reward points.

  • (SJAS9) Reading a context param in a web service

    Platform - SJAS9, NB5.5
    I am trying to add a web service to a small web project and I need database access for it.
    My web.xml defines 2 different resource-refs for my databases, jdbc/development and jdbc/production. There is also a global context-param named database with values of development or production that defines which database the web app should be using.
    I have two database pools set up under SJAS9 for these resource names, and the servlets can access these just fine using :
        protected Connection getConnection() {
            Connection conn = null;
            try {
                String datasourceName = "jdbc/" + getServletContext().getInitParameter("database");
                Context initCtx = new InitialContext();
                Context envCtx = (Context)initCtx.lookup("java:comp/env");
                DataSource ds = (DataSource)envCtx.lookup(datasourceName);
                log.debug("retrieving database connection for " + datasourceName);
                conn = ds.getConnection();
                log.debug("done");
                conn.setAutoCommit(false);
                return conn;
            catch (SQLException ex) {
                log.error("error getting a connection", ex);
                return null;
            catch (NamingException ex) {
                log.error("error finding the datasource", ex);
                return null;
        }I have just added a web service to the project, and I can't find a way to get the context param. When I created the web service, Netbeans added some annotation around it, and it is not extended any class or implementing any interface (that I can see).
    For the web service, there is no appropriate method equivalent for the call
                String datasourceName = "jdbc/" + getServletContext().getInitParameter("database");so how do I retrieve the context param database so I can know which resource pool to obtain the connection from inside the web service?
    Thanks
    Chris

    Here's how to invoke getServletContext() from a web service:
    First you'll need to add "ServiceLifecycle" to the list of implmentations of your class:
    public class MyService implements WebServices.MyServiceSoap, Remote, ServiceLifecycle {}Next you'll need to add the following:
    private ServletContext servletContext;
    public void destroy(){}  
    public void init(Object context) throws javax.xml.rpc.ServiceException {
       ServletEndpointContext soapContext = (ServletEndpointContext) context;
       servletContext = soapContext.getServletContext();
    Hope this helps!
    Peter

  • ServerSocket(TCP/IP) listening in the web container part

    So, if I implement the ServerSocket(TCP/IP) listening in the web container part (Websphere), what is the best way to do this?
    I need to monitor socket state and statistics from browser.
    When I receive message from socket, I must read something from database and send as response to client (meaning I need to create my own thread to do this).
    Solution:
    - to have one servlet with serverSoket listener in it or
    - during web application statup to start my own thread with serverSoket listener
    - or....
    Also there is a problem that websphere write warning when i try do use DB connection from thread I have created!
    Any suggestion?

    hi,
    do you use websphere? version?
    More details:
    http://www.javaranch.com/newsletter/200403/AsynchronousProcessingFromServlets.html
    According to a Technical note from WebSphere support "If a Servlet is spinning its own threads and accessing a database, the J2EE specification is not clear on this, so WebSphere Application Server 5.0 will allow it at this time. IBM is working with Sun to clarify this in the specification, so eventually (i.e. J2EE 1.4) spun threads from a Servlet accessing a database outside of a transaction will not be supported either". Later the same tech note states "Customers should consider changing their application to comply with the J2EE specification."
    and check this
    http://www-1.ibm.com/support/docview.wss?uid=swg21121449

  • Is there any way to edit the standard Firefox context menu for displayed Web pages?

    Is there any way to edit the standard Firefox context menu for displayed Web pages? I frequently want to save a picture appearing on a page. Sometimes I "slip" and hit "Send Image" when I want "Save Image As", and have to sit and wait for a default send-mail page to come up, then close it, fiddling with its "are you sure" dialogs. This is a painful way to handle a slip-up. I basically NEVER want to e-mail an element directly from a page. Is there any way I can just delete "Send Image" from the context menu?

    You can remove entries in the context menu with code in the userChrome.css file
    *http://kb.mozillazine.org/userChrome.css
    Some IDs are listed in this MozillaZine Knowledge Base article:
    *http://kb.mozillazine.org/Chrome_element_names_and_IDs
    To find the ID of others you will have to use the DOM Inspector.
    * https://support.mozilla.org/kb/DOM+Inspector
    * https://developer.mozilla.org/En/DOM_Inspector
    * https://developer.mozilla.org/en/Introduction_to_DOM_Inspector
    * DOM Inspector: https://addons.mozilla.org/firefox/addon/dom-inspector-6622/

  • Eclipse web project using Glassfish 4.1 can not load some libraries in modules directory

    We installed latest "Glassfish Tools for Luna" (updated on 2 October 2013) and created a new Eclipse dynamic web project using Glassfish 4.1. When try to annotate a class with "javax.enterprise.context.ApplicationScoped", it complains as "ApplicationScoped cannot be resolved to a type" although imported as "import javax.enterprise.context.ApplicationScoped".
    Checking "glassfish-4.1/glassfish/modules/" directory and there is cdi-api.jar that contains ApplicationScoped class. But when checking from the project libraries in the eclipse, couldnt see such a jar.
    My configuration:
    Eclipse 4.4
    Glassfish runtime java development kit : java 1.8.0_20
    Project java development kit : java 1.8.0_20
    Project compiler level : 1.8
    Project facets : Dynamic web module 3.1, Java 1.8, Glassfish Web Extensions 4.0, Javascript 1.0
    How to solve this issue?
    Thanks.

    There are 274 jars in the Glassfish 4.0 modules directory, whereas there are 282 jars in the Glassfish 4.1 modules directory. So it is not only cdi-api.jar. Moreover there are some libraries, the names of which have been changed.
    Why not simply importing all libraries in the modules directory to Eclipse, like Tomcat plugin does for tomcat/lib directory? So when manually deploying a library(jar) to modules directory Eclipse will discover it automatically.
    Thanks.

  • How to change the application alias for a web project in NW7.2

    Hi,
    a simple question, but I could not manage to solve it: How do I change the application alias (the url) of a web project? I'm using Netweaver 7.2 and all the tutorials I found refer to earlier versions and do not work anymore.
    In particular, I would like to change e.g. "server.com/vendor~webbappname" (the standard url of the web project) to "server.com/mywebapp".
    Thanks in advance for your help!

    Hi,
    Try customizing the <context-root> element in the web.xml deployment descriptor, for example:
    <?xml version="1.0" encoding="ASCII"?>
    <application xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
              http://java.sun.com/xml/ns/javaee/application_5.xsd"
               version="5">
               <display-name>YourWebApp</display-name>
               <module>
                   <web>
                   <web-uri>YourWebApp.war</web-uri>
                   <context-root>mywebapp</context-root>
              </web>
         </module>
         <module>
              <ejb>YourWebAppEjb.jar</ejb>
         </module>
    </application>
    Afterwards, rebuild and redeploy your application.
    I hope that helps.
    Regards,
    Yordan

  • Images do not show up in web project in J2EE application[/b]

    I have cretead a web project in which i hava a servlet and couple of jsp's and some java util classes. This application gets the data from the database and displays it on a screen. Beside displaying, this app also transform the xml document to html using. I have the the XSL Stlesheet under Web Content along with all the jsp's.
    I also have images folder under Web-Content which has all the images for this application. When i run the application using Oracle 10g application server within Jdev, the application cannot find the images or the xsl stylesheet. Relative path to images in jsp is /images/someimage.gif while relative path to xsl is /some.xsl. For some reason it cannot find the images or the xsl when the application runs or deployed in OC4J container. Any help on this will be appreciated.
    I have checked the path in reference to the context-root and it seems to be correct.

    Relative path to images in jsp is /images/someimage.gif while relative path to xsl is /some.xsl.
    Is the images dir under the jsp dir?
    If the images dir and the jsp dir are at the same level, the relative path would be ../images/someimage.gif

  • Jsf web project is not working in eclipse ConfigureListener

    Hi, I created a dynamic web project in eclipse with tomcat server, I also referenced the jsf jar files, besides the web.xml files contains <listener-class>com.sun.faces.config.ConfigureListener</listener-class>; even though when I run the web project or the jsp file, it appears with the following error:
    Estado HTTP 404 - /ejmweb6/start.jsp
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
    25-abr-2010 22:46:10 org.apache.catalina.core.StandardContext listenerStart
    Error configuring class listener com.sun.faces.config.ConfigureListener
    java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener
    java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletRequestListener
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
    Can you help me with problem? please
    Regards
    Carlos

    That class should be provided by the application server. Double check that the version of Tomcat you have supports servlet 2.4. Also check there are no bug reports against it for this error.

  • Web project architecture question, mulitple .wars vs a single .war

    I am in the early stage of architecting a web project.
    At this point, I've came up with two solutions:
    Multiple .wars
    Each section would be it's own .war that would be built into an .ear. This would allow a multiple developers to work on the project and if a change would be made, then only the changed .war would need to be built.
    However, then I would have mulitple copies of the same library for each .war, so that could slowly become a maintenance nightmare.
    Also, I haven't figured out how to communicate between each .war - I don't believe I can cross container context?
    Single .war
    I wouldn't have to worry about multiple copies of the same library files. Nor would I have to worry about losing session data between applications since I would be running under one container.
    But I am unsure of the best way to have more than one developer work on the project? It was suggested that I look at cruise-control at sourceforge.net - an automated build process - thus developers could check in their source code and a build would happen every xx minutes.
    What is the best way to approach a project that is made up of multiple applications that need to be under one application suite?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hi,
    I would recommend starting with the simple case which is using a single war file. You can use multiple wars, but it can add a bit of complexity and force you to learn a few advanced fetaures to get started. You can also share common libraries among multiple war files inside an ear file, and Java EE has mechanisms to allow that sharing (BluePrints has a document on adding libraries to Java apps at
    https://bpcatalog.dev.java.net/nonav/enterprise/portableextensions/frames.html ) but it is does add a bit of complexity for you to learn initially.
    A good rule of thumb is to start with one war file, and only split into other war files if really necessary. The most common style is one war file.
    hth,
    Sean

  • Calling struts actions between the two Web projects

    I don't know if it's the right forum for this question.
    Let's say I have two Web projects: MyProjectWeb and OtherProjectWeb.
    Each of them has they own struts-config.xml configuration and each of them has they own Web Deployment Descriptor (web.xml):
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    Links to the Actions in the two projects are:
    http://localhost:8080/MyProjectWeb/myRender.do
    http://localhost:8080/OtherProjectWeb/otherRender.do
    The question is how can I forward the action from MyProjectWeb to OtherProjectWeb ?
    The configuration in MyProjectsWeb struts-config.xml would look like this:
    <action path="/myRender" type="MyRenderAction" >
    <forward name="forward" path="/OtherProjectWeb/otherRender.do" contextRelative="false"/>
    </action>
    But it doesn't seem to work!
    Can somebody help me with this problem?

    As you've discovered, action paths are relative to the web application you're running on (so that you can deploy the app to any context path you want, without changing anything). They are not relative to the server. Therefore, forwards between webapps are not supported. Your best bet would be to redirect instead.
    By the way, a good source of help on Struts specific questions is the Struts user mailing list at Apache ... it's filled with helpful people, and the archives are a gold mine of good advice. To subscribe, send an empty message to <[email protected]>.
    Craig McClanahan

  • Moving .rpt files from a regular Crystal project to a Web project

    I created several reports in a regular Crystal Reports project, and I would like to move these to a Web Project.  What is the best way to do this?

    <p>Hi,</p><p>    The easiest way to do this is to create a new Crystal Reports Web Project in Eclipse. Once the project has been created you can either Import the reports into the project via the <strong>"Import..."</strong> command on the context menu of the project, or drag the reports from a Windows Explorer window to the Eclipse project.</p><p> This should be all that you need to do. </p><p>Regards,<br />Sean Johnson (CR4E Product Manager) <br /><br /> <a href="http://www.eclipseplugincentral.com/Web_Links-index-req-ratelink-lid-639.html">Rate this plugin @ Eclipse Plugin Central</a>          </p>

  • How to read file in netbeans web project with relative path.

    Hi friends,
    I have created a web project in Netbeans with following stucture.
    Exercise1
    src --> database --> ConnectionManager.java
    cofig --> databaseproperties.xml
    I want to read config\databaseproperties.xml file in src\database\ConnectionManager.java file.
    I have tried to create a file input stream with path = "config" File.separator "databaseproperties.xml".
    I am getting error of File Not Found..
    Anybody has any idea? In Netbeans what is the default context path?
    Edited by: Jaykishan on Jun 29, 2010 11:54 AM

    place the *.jrxml files in your war (e.g. WEB-INF\classes\report.jrxml) and then in your servlet:
    JasperReport report = JasperCompileManager.compileReport("report.jrxml");

Maybe you are looking for

  • Itunes library on an external hard drive

    I recently purchased an external hard drive to use for all of my media libraries (itunes, iphoto, etc). My first task was to move my iTunes library to the new HD.  I followed the steps from this Apple Support article (http://support.apple.com/kb/ht14

  • English-language server

    SAP BPC can only be installed on an English-language server including language settings and the same for SQL server version. As it is an important limitation for installation in an international context, I'd like to know if this limitation is planned

  • Prompting for Bluetooth Password - I never set one???

    My blackberry 8830 WE is constantly prompting me for a numeric or alphanumeric password to connect to my Acura's Hands Free Device. The problem is, I never set one. How I can I either reset the password or disable the feature? Thanks! Solved! Go to S

  • Causeless swap usage

    Hi! I noticed a performance hit lately when I am using my machine for a few hours, the cause was easy to find: it is swapping. The strange thing here that is my physical memory is not nearly full and it even swaps processes that i'm currently using,

  • Query on Formats and Destination

    Hello, can anyone of you pls respond to my qery: When I schedule a report in Business Objects, under Formats and Destinations, using a network directory, do I need to reset the password every time my network login password changes? I attached a  scre