• 2 replies
  • Latest Post - ‏2013-04-24T17:50:32Z by kevintap
12 Posts

Pinned topic Servlet Implementation In WEF

‏2013-04-24T06:10:45Z |

Hi All,


I need to implement a servlet in WEF. The servlet is running fine as a web application ,but i dont know how can i implement the same in WPF.

I have tried to changed it in to a LJO but that did not work as the servlet is getting called through URL mapping through a image tag on page load which

forms a captcha image at that  tag. Please let me know if any one has implemented a servlet using WPF.

A sample will  be really helpful.


Thanks in Advance 



  • Michael Burati
    Michael Burati
    2591 Posts

    Re: Servlet Implementation In WEF



    One option, instead of a servlet, may be to use the Content Launch builder and implement the code in a WEF :LJO, instead of adding a new servlet to your WAR/project.

    If you must add a servlet, then you should be able to add a servlet via the deployment descriptor extension mechanism.   Look in your project's WebContent/WEB-INF/bin/deployment/extensions folder.  The subfolders in there allow you to add extension fragments (eg, a servlet) to the various types of deployment descriptors.    There should be a readme file in each with info about how to do that.

    I hope that info helps,
    ..Mike Burati
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.


  • kevintap
    756 Posts

    Re: Servlet Implementation In WEF


    If you need to put a servlet in your WEF project, you should be aware that any classes placed in the standard Java source folders for the project (WebContent/WEB-INF/work/source) will end up being compiled to WebContent/WEB-INF/work/classes.  The work/classes and work/lib directories are special directories that are loaded by WEF's dynamic class loader.  The classes placed here can only be loaded by the WEF framework and not by the standard J2EE mechanisms.  In other words, these classes cannot be referenced in standard J2EE descriptors like web.xml or portlet.xml.

    There are some steps that you can follow to modify a WEF project to be able to create servlet classes.  These steps involve creating a second Java source folder and output folder in the Eclipse Designer and modifying the WEF project build scripts to compile these classes appropriately.

    right click the project, select Properties
    select the Java Build Path node
    select the Source tab
    check Allow output folders for source folders
    click Add Folder...
    select WebContent/WEB-INF in tree
    click Create New Folder...
    enter source for Folder name
    click Next >
    click Finish
    click OK
    change the Default output folder to: project/WebContent/WEB-INF/classes

    still in the Java Build Path dialog, expand the source folder project/WebContent/WEB-INF/work/source
    select Output folder
    click Edit...
    select Specific output folder
    select WebContent/WEB-INF/work/classes
    click OK

    click OK to close Properties dialog

    answer Yes to any prompts about changing the build path

    The steps above modify the WEF project to have 2 Java source folders which compile to 2 different output directories.  The WebContent/WEB-INF/source folder will compile to WebContent/WEB-INF/classes and can be used for creating J2EE standard artifacts like servlets.  The WebContent/WEB-INF/work/source folder will still compile to WebContent/WEB-INF/work/classes (as WEF projects normally do), and should be used for LJO classes used by your WEF models.

    The next step is to modify the project's projectDeploy.xml file (in the project's WebContent directory).  The compile target in projectDeploy.xml should be modified to also compile WEB-INF/source to WEB-INF/classes.  (You can copy/paste the existing contents of the compile target and change the source/target paths as appropriate.)

    After you have completed these steps, you will need to update the template files for web.xml or use the WEF deployment descriptor extension framework to add new fragments to the generated web.xml for your project.  Details on how to do this are in the product help as well as in the readme files under WEB-INF/bin/deployment/extensions in your project.

    Hope this helps.


    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.