Compiled Tomcat Servlet Example & got JAR, not WAR?

Is there a basic reference on how to create a simple servlet with NetBeans 4.1 and deploy it to Tomcat?
When I created the project I chose Samples->Web->Tomcat Servlet Example, and yet it does not create a WAR file on compilation.
And of course once I'm past that I have to figure out how to edit the XML file, I gather.
I need a reference that will hold me by the hand and walk me through it once to kick start me.
After that I think I can make it without having to ask such newbie questions.

Hi,
not sure to what extent you are clear in build.xml file (done thru ant).
what i can tell you is, ant creates any archive file (be it .jar, .war, .ear) with the tasks named "jar" (<jar jarfile="yourfilename.jar"..>), "war" and "ear". But both war and ear are the extensions of the jar only.
You can achieve creation of any archive file with the jar task itself.
you need to take care of the following...
(1) you can /should edit the extension of the files at every stage.. first .jar and then .war and then .ear (if necessary) => basic flow
(2) at every step, you have to have a file inclusion inside the corresponding archive file..
say for example, for a .jar file you should include all the compiled .class files, and ejb-jar.xml (incase you use ejbs) and other built-in jar files....
In case of .war files (web archive) you should include the web.xml file, any static files (html, jsp etc), any tld files - it goes with your application's nature and requirement.....
fyi, i m including a sample build.xml file which i use for a webapplication, so it deals with war...
<?xml version="1.0" encoding="UTF-8"?>
<project name="ServletsReqDispFwd" default="deploy">
     <property name="top" value="."/>
     <property name="webinf" value="${top}/WEB-INF"/>
     <property name="lib" value="${webinf}/lib"></property>
     <property name="classes" value="WEB-INF/classes"/>
     <property name="jboss.dir" value="D:\jboss-3.2.2RC3\server\default\deploy"></property>
     <property name="tomcat.dir" value="D:\jakarta-tomcat-4.1.27\webapps"></property>
     <property name="warfile" value="ServletsReqDispFwd.war"></property>
     <property name="src" value="${top}/src"/>
     <property name="web.xml" value="WEB-INF/web.xml"/>
     <target name="package">
          <javac srcdir="${src}" destdir="${classes}"
                 listfiles="true" debug="true"  verbose="true"
                      classpath="${lib}/*.jar"/>
          <war warfile="${warfile}" webxml="${web.xml}">
               <webinf dir="${top}">
                    <include name="**/*web*.xml"/>
                    <include name="**/*application*.xml"/>
                    <exclude name="src/**/*.xml"/>
               </webinf>
               <lib dir="${lib}">
                    <include name="*.jar"/>
               </lib>
               <fileset dir="." includes="**/*.html"/>                    
               <classes dir="${classes}" includes="**/*.class"></classes>                         
          </war>
     </target>
     <target name="deploy" depends="clean,package">
          <copy file="${warfile}" todir="${tomcat.dir}" overwrite="true"></copy>
     </target>
     <target name="clean">
            <delete dir="${classes}">
                 <filename name="*.class"/>
          </delete>
          <delete>
               <fileset dir="${top}" includes="${warfile}"/>
          </delete>
          <delete>
               <fileset dir="${tomcat.dir}" includes="${warfile}"/>
          </delete>
     </target>
</project>hope this contribues to a certain extent to help you edit the buildfile (xml file as you go) to meet your requirement.....

Similar Messages

  • CiscoWorks Tomcat Servlet Engine service does not start

    Hello!
    CiscoWorks  Tomcat Servlet Engine service does not start.
    Events in the Windows Event Viewer:
    The CiscoWorks Tomcat Servlet Engine service terminated unexpectedly. It has done this 1 time(s).
    output pdshow and file stderr.log,  hs_err_pid2128.log attached.
    Do  you have an idea how to resolve this?
    Thanks!

    The only things which I see are wrong are the start types for the IPM NG database engine and HUM database engine services.  They must be set to Manual, not Automatic.  However, that would not account for the Tomcat crash.  The crash points to an error in the code which processes regdaemon.xml, but I see no reason why that should be failing.  As I said before, I think it would be best to open a Service Request.  Remote access would be helpful to dig into this problem in more detail.
    Please support CSC Helps Haiti
    https://supportforums.cisco.com/docs/DOC-8895
    https://supportforums.cisco.com

  • J2EE tutorial (June 17 '04) servlet example compilation error

    This is a copy of my previous post on the same topic, but this one has a more self-desriptive subject line. Apologies for duplication.
    I am trying the first servlet example in the J2EE tutorial, June 17, 2004, pgs 443 - 448. I have completed all the steps as described. However, the URL results in the following error. I would like to point out that I am using the URL http://localhost:8081/bookstore1/bookstore (instead of port 8080 because the admin console suggests that port 8081 is an available http port):
    Assistance would be appreciated.
    HTTP Status 404 - /bookstore1/bookstore
    type Status report
    message /bookstore1/bookstore
    description The requested resource (/bookstore1/bookstore) is not available.
    Sun-Java-System/Application-Server-PE-8.0
    I looked at the logviewer and there are 3 severe errors in the log:
    1. Application Server
    Log Entry Detail
    Details
    Timestamp: Aug 6, 2004 14:36:28.375
    Log Level: SEVERE
    Logger: javax.enterprise.system.container.web
    Name-Value Pairs:
    _ThreadID=12;
    Record Number: 754
    Message ID: WebModule[bookstore1]Exception sending context initialized event to listener instance of class listeners.ContextListener java.lang.NoClassDefFoundError
    Complete Message
    exception/OrderException
    at listeners.ContextListener.contextInitialized(Unknown Source)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3679)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4140)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:873)
    at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:171)
    at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:193)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:855)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:623)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:947)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:729)
    at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:147)
    at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:224)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:488)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:475)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:302)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:107)
    at com.sun.enterprise.admin.server.core.mbean.config.ManagedServerInstance.multicastEvent(ManagedServerInstance.java:3880)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.sun.enterprise.admin.server.core.jmx.Introspector.invokeMethodOn(Introspector.java:181)
    at com.sun.enterprise.admin.server.core.mbean.config.AdminBase.invoke(AdminBase.java:86)
    at com.sun.enterprise.admin.server.core.mbean.config.ConfigMBeanBase.invoke(ConfigMBeanBase.java:680)
    at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:221)
    at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:228)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:823)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792)
    at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:54)
    at $Proxy1.invoke(Unknown Source)
    at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:282)
    at com.sun.enterprise.deployment.phasing.DeploymentService.multicastEvent(DeploymentService.java:341)
    at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:284)
    at com.sun.enterprise.deployment.phasing.StartPhase.runPhase(StartPhase.java:115)
    at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:74)
    at com.sun.enterprise.deployment.phasing.DeploymentService.executePhases(DeploymentService.java:233)
    at com.sun.enterprise.deployment.phasing.DeploymentService.deploy(DeploymentService.java:150)
    at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.deploy(ApplicationsConfigMBean.java:275)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:287)
    at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:280)
    at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:221)
    at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:228)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:823)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792)
    at sun.reflect.GeneratedMethodAccessor74.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:54)
    at $Proxy1.invoke(Unknown Source)
    at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:282)
    at com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(InvokeCaller.java:38)
    at com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(MBeanServerRequestHandler.java:92)
    at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.processRequest(RemoteJmxConnectorServlet.java:69)
    at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.doPost(RemoteJmxConnectorServlet.java:94)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:768)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
    at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:289)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:311)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:283)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:102)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:192)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:156)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:569)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:261)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:215)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:156)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:583)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:154)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:569)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:200)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:156)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:180)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:154)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:582)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:154)
    at com.sun.enterprise.webservice.EjbWebServiceValve.invoke(EjbWebServiceValve.java:134)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:154)
    at com.sun.enterprise.security.web.SingleSignOn.invoke(SingleSignOn.java:254)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:154)
    at com.sun.enterprise.web.VirtualServerValve.invoke(VirtualServerValve.java:209)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:154)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:569)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:161)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:156)
    at com.sun.enterprise.web.VirtualServerMappingValve.invoke(VirtualServerMappingValve.java:166)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:154)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:569)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:979)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:211)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:692)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:647)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:691)
    at java.lang.Thread.run(Thread.java:534)
    2. Application Server
    Log Entry Detail
    Details
    Timestamp: Aug 6, 2004 14:36:28.375
    Log Level: SEVERE
    Logger: tomcat.server./bookstore1.Context
    Name-Value Pairs:
    _ThreadID=12;
    Record Number: 755
    Message ID:
    Complete Message
    Error listenerStart
    3. Application Server
    Log Entry Detail
    Details
    Timestamp: Aug 6, 2004 14:36:28.375
    Log Level: SEVERE
    Logger: tomcat.server./bookstore1.Context
    Name-Value Pairs:
    _ThreadID=12;
    Record Number: 756
    Message ID:
    Complete Message
    Context startup failed due to previous errors

    I had the same problem. It was caused by not including \j2eetutorial14\examples\web\bookstore\dist\bookstore.jar in the bookstore1.war. You may need to build the bookstore.jar file first if you haven�t already.

  • J2ee.jar not compatible with Tomcat 4.1.18 - HELP

    I am attempting to generate my first web page using EJBs. I have ran into a snag. It seems that Tomcat 4.1.18 is not compatable with j2sdkee1.4. I have tried using j2sdkee1.3.1 and got the same problem.
    Ant builds the project just fine therefore I believe this to be a configuration problem - but can not find it. HELP
    *** Below is the out put from Tomcat when he is starting up....
    Feb 3, 2003 11:50:31 AM org.apache.commons.modeler.Registry loadRegistry
    INFO: Loading registry information
    Feb 3, 2003 11:50:32 AM org.apache.commons.modeler.Registry getRegistry
    INFO: Creating new Registry instance
    Feb 3, 2003 11:50:32 AM org.apache.commons.modeler.Registry getServer
    INFO: Creating MBeanServer
    Feb 3, 2003 11:50:33 AM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on port 8181
    Starting service Tomcat-Standalone
    ********** Probjem with Jar ************
    Apache Tomcat/4.1.18
    WebappClassLoader: validateJarFile(C:\Program Files\Apache Group\Tomcat 4.1\weba
    pps\JobEntry\WEB-INF\lib\j2ee.jar) - jar not loaded. See Servlet Spec 2.3, secti
    on 9.7.2. Offending class: javax/servlet/Servlet.class
    *** Below is the compiler output
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\JobEntry\index_jsp.java:9: package javax.ejb does not exist
    import javax.ejb.*;
    ^
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\JobEntry\index_jsp.java:23: cannot resolve symbol
    symbol : method InitialContext ()
    location: class org.apache.jsp.index_jsp
    InitialContext initial = InitialContext();
    ^
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\JobEntry\index_jsp.java:25: cannot access javax.ejb.EJBObject
    file javax\ejb\EJBObject.class not found
    siteList = (JobEntry.SiteList) PortableRemoteObject.narrow(objectRef, SiteList.class);
    ^
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\JobEntry\index_jsp.java:26: cannot resolve symbol
    symbol : variable siteListHome
    location: class org.apache.jsp.index_jsp
    mySiteList = siteListHome.create();
    ^
    4 errors

    You should not add j2ee.jar to the WEB-INF folder. I think you should move it to "C:\Program Files\Apache Group\Tomcat 4.1\lib\j2ee.jar".
    Also, it might help to read section 9.7.2 in the servlet 2.3 specification (as stated in the error). You can download the spec here: http://www.jcp.org/aboutJava/communityprocess/final/jsr053/

  • Jar not loaded Error when deploying weblogic.jar in tomcat

    Hi experts,
    This time i have one more problem,
    i have deployed my application in tomcat such that when tomcat starts my java program also gets started, for my java program i had to use a weblogic library which is in "web-inf / lib / weblogic.jar" . but when i start tomcat i get error like
    INFO: validateJarFile (C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MyApp\WEB-INF\lib\weblogic.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    Dec 4, 2006 8:27:18 PM org.apache.catalina.core.StandardPipeline registerValve
    INFO: Can't register valve org.apache.catalina.core.StandardContextValve@1362012
    org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@1bc82e7 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@1bc82e7
    for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
            at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
    what could be the problem in loading weblogic.jar
    my platform configuations are
    TOMCAT 5.5
    OS - windows 2000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

              have u done the servlet naminga and mapping in the web.xml file??
              Kumar Allamraju <[email protected]> wrote:
              ><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
              ><html>
              >Have you registered the servlet in web.xml?
              ><p>--
              ><br>Kumar
              ><p>Deepak Balakrishna wrote:
              ><blockquote TYPE=CITE>Hi.
              ><p>I am having trouble deploying a servlet to WLS 6.1
              ><p>a) The name of the servlet is HaServlet and it's duly noted in web.xml
              ><br>b) I created a directory
              ><br>config/examples/applications/cluster-servlet/WEB-INF
              ><br>c) Added web.xml under WEB-INF/. web.xml was created using the weblogic
              ><br>DDInit CLI
              ><br>d) Added the servlet classfile (HaServlet.class) under
              ><br>WEB-INF/classes/samples/cluster/servlet/.
              ><br>e) Tried to access it by http://host:port/cluster-servlet/HaServlet
              ><p>I get
              ><br>Error 404--Not Found
              ><p>What am I missing? I also tried restarting the app server to no avail.
              ><p>Thx,
              ><br>- deepak</blockquote>
              ></html>
              >
              

  • Calling servlets in another jar/war

    I am working on an integration project.
    I have a war file that has many of the components that I need.
    In my new project (Sun Studio IDE), I am trying to call up a servlet that exists in this other war file.
    I can mount the war file as a directory, just like mounting a jar for use like classes12.zip whatever or similar to including a jar in your classpath.
    Can I call a servlet in another jar, war, or zip file from my existing code?
    How will the existing code or jsp know where to find this servlet outside the project?
    Usually you have to either map the servlet or set this info in the web.xml, I think.
    If the servlet mappings are in the web.xml, does that mean that if I access a servlet in another war, with it's own web.xml, does that mean that I have to map that servlet in my current projects web.xml also?
    Thanks

    Can I call a servlet in another jar, war, or zip file
    from my existing code?
    How will the existing code or jsp know where to find
    this servlet outside the project?When you say 'call' I assume you mean forward. Yes, you can forward to servlets in other contexts/wars.
    If the other context is say 'appB' you can forward the request to a servlet mapped as say '/test' in web.xml of appB in the following way:
    getServletContext().getContext("/appB").getRequestDispatcher("/test").forward(request,response);
    Usually you have to either map the servlet or set this
    info in the web.xml, I think.
    If the servlet mappings are in the web.xml, does that
    mean that if I access a servlet in another war, with
    it's own web.xml, does that mean that I have to map
    that servlet in my current projects web.xml also?No. You don't need to map it again. However as you might have noticed, you do need to know the url pattern of the other servlet, so that you can forward properly.
    But beware - Session info will not be shared in cross-context forwarding

  • Can not compile a servlet!

    Hi!
    so.. I import
    import javax.servlet.*;
    import javax.servlet.http.*;
    ..and then I write mi servlet. But javac tels me :
    HttpServlet .. no such thing !
    What shall I do ?

    do you have servlet.jar included in your classpath? do you have a servlet runner? if not, go to jakarta.apache.org and download tomcat.

  • How to Compile/Run servlet in Tomcat 4.1

    Hi All,
    iam trying to compile my servlet program in tomcat4.1.. but its showing an error
    in the import statement..
    UN SOLVABLE SYMBOL... but the import ststement is correct...
    can any one help ... is there i have to set any path for compiling/running the servlet...
    Thanks in Advice

    hi thanks for your reply
    i have loaded tomcat4.1 exe -- for windows i am starting the tomcat server by clicking from the start menu..
    i dint set any env variable .. tell me how to set...
    regards
    ijay

  • Error in compiling: file javax\servlet\jsp\PageContext.class not found

    Hi,
    i'm getting an error when I'm trying to compile an java file. The error is as follows:
    cannot access javax.servlet.jsp.PageContext
    file javax\servlet\jsp\PageContext.class not found
    Isn't the javax package included in jdk? I've installed jdk 1.3.1_03 and j2re1.4.0_02. Shouldn't this PageContext.class be automatically loaded when i've installed jdk?
    I'm getting desperated! I've tried almost everything: i've changed the classpath, moved the directory of the java file I'm trying to compile over and over but i'm getting no success!
    Any help is very welcome!
    Thankx,
    Nuno.

    hmmm... i had a look and it seems that what you are trying to "import" is actually in a package... instead of import try:
    package javax.servlet.jsp;you may need to go download this "package" and complile it in the directory you are working in.
    my advice: try the above statement (which does compile for me), if it doesn't work, you will need to find the source code for this package and compile it just like you do any other source code.
    hope this helps.

  • Can not create i.war using java -jar ords.war static

    C:\glassfish4\ords>java -jar ords.war static "c:\app\sybrandb\apex_4.2.6\apex\im
    ages"
    WAR Generation complete
    WAR location     : C:\glassfish4\ords\i.war
    Context path     : /i
    Static resources : c:\app\sybrandb\apex_4.2.6\apex\images
    Ensure the static resources are available at path: c:\app\sybrandb\apex_4.2.6\ap
    ex\images
    on the server where the WAR is deployed
    I downloaded ORDS from OTN yesterday
    Needless to say this directory does exist (it works when I run the listener standalone, providing this path)
    Why is everything which Oracle releases in this area always broken and badly documented?
    HELP!
    Sybrand Bakker
    Senior Oracle DBA

    To create the manifest, you use the constructor
    JarOutputStream(OutputStream out, Manifest man).
    However, I am having problems with creation of my files and I came here to look for answers. No .war file i have created has been deployable.

  • Tomcat 5.0.19 is not running in Windows XP

    I have installed Tomcat 5.0.19 in Windows XP Professional. But I am unable to make it run.
    i)From the config Tomcat I have given as:
    1.In the description I have given as Apache Tomcat 5.0
    2.In the Image Path I have given as E:\Tomcat 5.0\bin\bootstrap.jar
    3.In the Work Path I have given as E:\Tomcat 5.0
    4. In the user name and password I have given the appropriate user name and password
    I have checked AutoStart check box.
    ii)In the JVM tab I have given as auto and left all the fields empty.
    I have given apply and ok but when I given again Config Tomcat fromt he start menu I cannot find the variables which I have set.
    iii) In the Environment Variables I have given as
    JAVA_HOME=E:\jdk1.3.1_06
    iv)In the service from the bin I have given it as
    service install
    v) When I give start Tomcat from the start menu
    It splash screen appears and after some time the message showing
    "Service is not found" message appears and when I click on OK the Tomcat icon present in the TaskBar closes
    TIA

    when i installed tomcat 5.0.19 i didn't set environment variable JAVA_HOME so it run well but i have another problem
    i 've installed tomcat 5.0.18 on windows XP, with jdk 1.3.1 when i use the link : http://localhost:8080 it run well, it also run well when i executed http://localhost:8080/servlets-examples/ and http://localhost:8080/jsp-examples/ files. But when i tried to execute these file : http://localhost:8080/tomcat-docs/appdev/sample/web/hello.jsp and http://localhost:8080/tomcat-docs/appdev/sample/web/hello it got error
    For hello.jsp:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    F:\Tomcat 5.0\work\Catalina\localhost\tomcat-docs\org\apache\jsp\appdev\sample\web\hello_jsp.java:8: cannot access java.lang.Object
    bad class file: F:\Program Files\Java\j2re1.4.2_03\lib\rt.jar(java/lang/Object.class)
    class file has wrong version 48.0, should be 47.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    implements org.apache.jasper.runtime.JspSourceDependent {
    ^
    1 error
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    note The full stack trace of the root cause is available in the Tomcat logs.
    For Servlet file
    type Status report
    message /tomcat-docs/appdev/sample/web/hello
    description The requested resource (/tomcat-docs/appdev/sample/web/hello) is not available.
    I didn't know the reason why so anybody cound help me.
    And another problem if i want to test a servlet file and jsp file. Where i can put this file and how to configure to test these kind of files

  • JWSDP Tutorial - Servlet Example

    I am trying to run the bookstore example in the Servlet section of the JWSDP on Red Hat 7.3.I am also getting confused over ANT and the Tomcat Manager.
    I need to build the bookstore example and the instructions read: (for those who know the tutorial)
    1. In a terminal window, go to /docs/tutorial/examples/web/bookstore1
    2. Run ant build - The build target will spawn any necessary compilations and copy files to the docs/tutorial/examples/web/bookstore1/build directory.
    3. Make sure Tomcat is started.
    4. Run ant install - The install target notifies Tomcat that the new context is available.
    5. Start the Pointbase database server and populate the database if you have not done so already
    6. Open the bookstore URL http://localhost:8080/bookstore1/enter
    On the command line I can run ANT BUILD fine, but ANT INSTALL fails. (It also fails in Tomcat Manager...but not sure whether I can use this instead of ANT INSTALL?)
    I know this is sketchy but does anyone have any idea?
    Regards
    Scott

    Hi Scott,
    Thank you any way.
    Last time, I met it and carried the tutorial on by compiling and copying manually. Then, I came back to set the ant.jar into path&classpath, and it worked.(ant build)
    Today, I'm trying on "hello1" example, but can't get though.
    Maybe it's still classpath and path issue, as I can't compile two servlet classes by javac from command line, but from Forte, it passed.
    Cheers!
    Zhan

  • Tomcat Servlet - TCP Port Already in Use?

    My problem is that tomcat/servlet is not releasing its TCP port after my servlet closes the port. Next time a servlet tries to use the port it gets an error "Port already in use". Using netstat I can see the port is still in use. If I stop tomcat and restart it, the port is released. I have not had this sort of problem writing C programs that use sockets.
    My setup is Fedora Core 6 with JDK1.5_14 and Tomcat 5.5.26. I know it's not the latest, but sockets and streams have been around for a long time.
    Actual implementation uses a trivial javaserver page to instantiate a class to create/accept connection from a client (JApplet). After connection, it starts a thread to receive data. I am using ServerSocket(), InputStreamReader(), and OutputStreamWriter(). On ServerSocket I set ReuseAddress to true.
    I have try/catch on all my I/O and use tomcat context log for error and OK messages. Data transfer is perfect. Detect close by client works. In the context log I see close of streams and ServerSocket occur with no exceptions. Then, I manually close the jsp window. No indication of any problems. If I use different port 2nd time (e.g. 50001) it all works perfect. If I use my default (50000) again, servlet gets an error during bind, "Port already in use".
    2.5 years with Java. 5 years with Linux and C.
    Please advise or refer

    rwengr wrote:
    My problem is that tomcat/servlet is not releasing its TCP port after my servlet closes the port. Next time a servlet tries to use the port it gets an error "Port already in use". Using netstat I can see the port is still in use. If I stop tomcat and restart it, the port is released. I have not had this sort of problem writing C programs that use sockets.Nice.... Not sure that matters though.
    >
    My setup is Fedora Core 6 with JDK1.5_14 and Tomcat 5.5.26. I know it's not the latest, but sockets and streams have been around for a long time.
    Actual implementation uses a trivial javaserver page to instantiate a class to create/accept connection from a client (JApplet). Bleah! Don't use a JSP for that. Use a servlet at worst. At best use a Servlet to start some other socket manager class which you can/have tested outside the Servlet Container environment.
    After connection, it starts a thread to receive data. I am using ServerSocket(), InputStreamReader(), and OutputStreamWriter(). On ServerSocket I set ReuseAddress to true.
    I have try/catch on all my I/O and use tomcat context log for error and OK messages. Data transfer is perfect. Detect close by client works. In the context log I see close of streams and ServerSocket occur with no exceptions. Then, I manually close the jsp window. Closing the browser window has no affect on the server.
    No indication of any problems. If I use different port 2nd time (e.g. 50001) it all works perfect. If I use my default (50000) again, servlet gets an error during bind, "Port already in use".
    2.5 years with Java. 5 years with Linux and C.
    Please advise or referShow some code. If you just want some generic advice it would be to close the port, as soon as you don't need it anymore. But you know that. Without any further code I think that is about all that can be said.
    P.S. Make the code as small as possible, compilable, but still demonstrating the problem. Also see: [this tutorial as an example...|http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html?page=1]

  • How to compile a servlet

    I am trying to compile a servlet using the import javax.servlet.*;
    import javax.servlet.http.*; packages. But the only thing I keep getting is :
    BasicServlet.java:1: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    BasicServlet.java:2: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    BasicServlet.java:6: cannot resolve symbol
    symbol : class HttpServlet
    location: class BasicServlet
    public class BasicServlet extends HttpServlet
    I have included the servletapi2_1_1-win package from the sun site containing the servlet.jar in my classpath. Still it refuses to compile. Besides does anybody know how to compile using the servlet packages available in Tomcat or j2ee, both of which I have on my machine , but can't figure what to include.
    Please help.
    ^

    have you actually included the servlet.jar file in your classpath or just the directory, as you need to explicity declare jar files in the classpath...
    javac -classpath %CLASSPATH%;C:\[servlet-jar-path]\servlet.jar Servlet.class

  • Servlet Class dependency is not found at weblogic startup.

    I have the following ear file which includes:
    web-inf\lib (contains all the needed utilities jar)
    *ejb.jar
    *webapp.war (The WEB-INF\lib dir inside war file contains all the needed utilities
    jars.
    I get the following BEA-101250 error saying that a servlet could not be loaded
    because a class that it depends on is not in the classpath. But I think I place
    all the needed jars in the startWebLogic.cmd file as well as in the WEB-INF\lib
    of the ear and war files. However, if a classs that a servlet depends on is not
    found, why doesn't weblogic simply tells us what that class is (instead of guessing
    to death)? How can I find which class that the servlet depends on is not found?
    Thanks.
    BEA-101250
    Error: [context]: Servlet class className for servlet svltName could not be loaded
    because a class on which it depends was not found in the classpath classPath.\nt.
    Description
    [context]: Servlet class className for servlet svltName could not be loaded because
    a class on which it depends was not found in the classpath classPath.\nt.
    Cause
    One of the classes the servlet class uses was not recognized by the Web application
    classloader.
    Action
    Make sure the class is available either in WEB-INF/classes or WEB-INF/lib or
    system classpath.

    Hmm, do you perhaps have the prefer web-inf-classes set in weblogic.xml?
    -- Rob
    rock wrote:
    I place all the utilties class in the top level APP-INF/lib. Same error. I installed
    this application on JBoss and everything runs fine. I really don't know what
    classes or jar that weblogic says that a servlet depends on.
    There are only a finite number of places where you can put all the needed jars
    in which that servlet depends:
    1. myapp.ear/APP-INF/lib
    2. myapp.ear/WEB-INF/lib
    3. or put it to a directory in the ear and refer to each jars in the CLASS-PATH
    line of the MANIFEST.MF file.
    4. myweb.war/WEB-INF/lib
    5. EJBs are in myapp.ear top directory
    6. Refer to all the jars in startWebLogic.cmd script as it starts.
    I still don't know what jars I am missing.
    Thanks.
    Rob Woollen <[email protected]> wrote:
    rock wrote:
    Rob,
    I remove all the classpath, but when I deploy the ejb complains thatit missed
    all the needed utilities class. Ok, stop there. If the utilities classes need to be seen by both the
    EJBs and webapp, then placing them in WEB-INF/lib is not enough. That
    makes them available only to the webapp.
    If you're using 8.1, then the solution is pretty simple. Move your
    utility classes into a top-level directory named APP-INF/lib
    ie
    ear/APP-INF/lib/utils.jar
    ear/fooejb.jar
    ear/fooweb.war
    If you're using < 8.1, then you can still move the jars to APP-INF/lib,
    but you'll need to add manifest class-path entries to the EJB and webapp.
    -- Rob
    I again place it on - the ear deploys fine (ejbs
    and war). But the starting servlet could not loaded because it cannotfinds a
    class that it depends on. I think I reference all the classes or jarsthat it
    needs - so I need it to tell me which one. I don't know why weblogicmakes it
    so difficult. It took me a month already and all I need to do is findthe class
    that it complains about.
    Rob Woollen <[email protected]> wrote:
    Yes, it would be nicer if that exception had more information.
    You told the web container the servlet-class in your web.xml. THe
    web
    container tried to load it and got a NoClassDefFoundError.
    Unfortuantely that exception doesn't include much information.
    NoClassDefFoundErrors are caused by something in a parent loader
    depending on something in a child classloader.
    Step #1 is for you to remove everything you've added to the $CLASSPATH.
    If that doesn't solve your problem, post again.
    -- Rob
    rock wrote:
    I have the following ear file which includes:
    web-inf\lib (contains all the needed utilities jar)
    *ejb.jar
    *webapp.war (The WEB-INF\lib dir inside war file contains all the
    needed
    utilities
    jars.
    I get the following BEA-101250 error saying that a servlet could notbe loaded
    because a class that it depends on is not in the classpath. But Ithink I place
    all the needed jars in the startWebLogic.cmd file as well as in theWEB-INF\lib
    of the ear and war files. However, if a classs that a servlet dependson is not
    found, why doesn't weblogic simply tells us what that class is (insteadof guessing
    to death)? How can I find which class that the servlet depends onis not found?
    Thanks.
    BEA-101250
    Error: [context]: Servlet class className for servlet svltName couldnot be loaded
    because a class on which it depends was not found in the classpathclassPath.\nt.
    Description
    [context]: Servlet class className for servlet svltName could notbe loaded because
    a class on which it depends was not found in the classpath classPath.\nt.
    Cause
    One of the classes the servlet class uses was not recognized by theWeb application
    classloader.
    Action
    Make sure the class is available either in WEB-INF/classes or WEB-INF/libor
    system classpath.

Maybe you are looking for

  • Create fixed assets from within the transaction for creating the purchase order

    Hello All, I have gone through the notes on help.sap.com related to automatic creation of asset master record at the time of creating purchase order.  I am not sure how do we achieve this? Link to the notes on help.sap.com SAP Library - Asset Account

  • How do i transfer windows formatted 2005 iPod to my macbook air?

    How do i transfer my old Windows formatted iPod (2005 model: 60GB video iPod model no. A1136) to my new MacBook Air (OS X 10.10)? I don't have a PC anymore to transfer to first. My Mac doesn't even recognize that there is a device when I plug it into

  • Deleting CAF-Entity-Tables

    Hello! In a former  I already asked how to delete the database tables that are generated by CAF for entity-services. There are got some answers for maxDB. The problem is, we use Oracle. It version is 10.1.0.4.0, I think, I can see it in db13-transact

  • Error Applying BASIS Support Patch 10

    Dear all, I am facing syntax errror when i apply basis support patch 10.When i try to enter any T code its give me syntex error. And spam status show error stop IMPORT_PROPER Runtime Errors         SYNTAX_ERROR Date and Time          30.12.2008 01:31

  • Imac shuts off by itself

    It just started about three hours ago, but my iMac keeps unexpededly shutting off by itself. It's not exactly hot, but I do play an online game but it has never done this before. Its shut off 3 times now, and the longer I keep it off the longer it st