How to Run a simple servlet "HelloWorld.java" in JBoss 3.0 ?

Dear all,
I am a beginner and I want to run a simple "HelloWorld.java" servlet .
I need to use JBoss 3.0 .
After I run this simple servlet, I need to use EJB-Servlet-JSP to implement MVC .
I have the servlet code and I am able to compile it.
But I dont know how to proceed as to where to put the class files , where do I specify an alias for my servlet and what modifications I need in Web.xml,Jboss.xml,Application.xml ?
I do not anything about tools like Ant or Xdoclet so need to proceed without them.Please alos let me know where I can fond complete info about Ant and Xdoclet .
Thanx in Advance,
Sujith

I am not sure of the JBoss package that you are using. If you are using the JBoss-Tomcat package, here's the solution. Create either a .war file or create a directory with the name <your-webapp>.war under <jboss-root>/server/default/deploy. If you are creating a war file, you have to place that war file in the same directory. JBoss-Tomcat will keep looking at this directory for new files or updates to files and deploys/re-deploys as required.
The contents of the war file should be something like this.
WEB-INF - directory
WEB-INF/classes - your servlet classes
WEB-INF.web.xml - your configuration. Here you can specify the servlet name, class and URI mapping.
Now, you can call your servlet using the browser in this way: http://localhost:8080/<your-webapp>/servlet/<servlet-alias>. Here the <your-webapp> is the prefix of the .war file.
Resources:
Ant - http://jakarta.apache.org/ant/
Xdoclet - http://xdoclet.sourceforge.net/

Similar Messages

  • How to run and compile servlets using tomcat4.0.3

    Hello
    I have simple servlet "HelloWorld".I have doubts in compiling and running this servlet.I'm using server Tomcat 4.0.3 as and JDK1.3.
    1)where do i need to save this servlet?
    2)how to compile this servlet by setting a classpath?
    3)how do i run this after compilation?
    4)do i need any HTML page to run on browser?.if, so how do i have a reference of servlet in HTML page?
    HERE IS THE SIMPLE SERVLET
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<body>");
    out.println("<head>");
    out.println("<title>Hello World!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Hello World!</h1>");
    out.println("</body>");
    out.println("</html>");
    Thanx for help

    put your helloworld servlet inside of webapps/example/WEB-INF/classes...
    and then start your tomcat..and type
    http://localhost:8080/webapps/servlet/HelloWorld
    S

  • How to run the simple jsp on oracle 9ias application server?

    hi,
    how to run the simple jsp application jst disply the date on oracle 9ias application server?
    can any expline the steps how to do it?
    thanks
    pullareddy

    No, you need the Reports Server (as part of the Application Server or Weblogic, depending on your version).
    I try to save the report, it's saved as .jspThat depends. You can save it as a .rdf file too (so called Paper Layout). I think this option is used more often.

  • How to run a jar file using Java application.

    Hi all,
    I know that jar file can run using the following command, using the command prompt.
    java -jar jar-fileBut I don't know how to run that command through a Java code. Hope it's clear to you.
    So can you please explain how can I do it.
    Thanks,
    itsjava

    rayon.m wrote:
    The solution given by ropp appears to have nothing to do with what you asked about.Ok sir, I got the point.
    I've try a test as follows. But it doesn't give any output. Even not an exception.
            try {
                String[] temp = new String[]{"java", " -jar", " MainApp.jar"};
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec(temp);
                int exitVal = proc.waitFor();
                System.out.println("ExitValue: " + exitVal);
                System.out.println("Temp_Values");
            catch(InterruptedException ex) {
                System.out.println(ex.getMessage());
            catch (IOException ex) {
                System.out.println(ex.getMessage());
            }I've debug and see, but the exitValue is even not exist at run time. Can you tell me where I'm going wrong.

  • How to run a remote application (Non Java) from a Java program

    Could you please tell me how to run a remote application (Non-Java) from a Java program without using RMI. Please tell me know the procedure and classes to be used.
    Cheers
    Ram

    what do you mean remote application.In the other pc or in your pc just apart from you application?
    If the application is in your pc,the method which the upper has mentioned is
    a good one!
    But if the application you want to run is not in your computer,the method can't do. And you can use socket with which you can build an application listening some port in the pc which contains the application you want to run .When you want to run that application ,send the Start_Command to the listening application.Then listening application will run the application with the help of the method the upper mentioned.

  • How to run the simple java card program in eclipse?

    I am trying to run a simple HelloWorld program in eclipse 3.5 having java card development kit 2.2 installed in it.
    Firstly,I go to the JCWDE tab and press start..then when trying to deploy that package its giving me error like " com.hw.HelloWorld: unsupported class file format of version 50.0." can any one help me in this what is this error???n how to resolve n run this program..

    Hi,
    It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
    Cheers,
    Shane

  • How to run a simple shell comnd line on cygwin thru java class ?

    Hi
    I want to run a simple shell command "dir" on cygwin thru java class. My code is as follows :-
    public class CygJava {
         public static void main (String args[]){
              File workDir = new File("c:/cygwin/bin");
              try {
                   Runtime systemShell = Runtime.getRuntime();
                   Process shellOutput = systemShell.exec("dir", null, workDir);
                                                 InputStreamReader isr = new InputStreamReader(shellOutput.getInputStream());          
                   BufferedReader br = new BufferedReader (isr);
                   String line = null;
                   System.out.println("<OUTPUT>");
                   while((line = br.readLine()) != null ) {
                   System.out.println(line);
                   System.out.println("</OUTPUT>");
                   int exitVal = shellOutput.waitFor();
                   System.out.println("Process Exit Value : "+exitVal);
              }catch (IOException ioe) {
                   System.err.println(ioe);
              } catch (Throwable t) {
                   t.printStackTrace();
    On running this program , i get the error as :-
    java.io.IOException: CreateProcess: dir error=2
    Could anyone tell me as to why is this error occuring ?
    Thanks

    Hi guys,
    I am trying to launch a linux-environment application using cygwin from my java application.
    I already included the c:\cygwin path in the environment path of my computer, so if i run cygwin from windows console everything goes fine. But if i do the same from my java application, i get an error message:
    java.io.IOException: CreateProcess: cygwin error=2
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
         at java.lang.ProcessImpl.start(ProcessImpl.java:30)
         at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
         at java.lang.Runtime.exec(Runtime.java:591)
         at java.lang.Runtime.exec(Runtime.java:429)
         at java.lang.Runtime.exec(Runtime.java:326)
         at prueba.Prueba.jButton1_actionPerformed(Prueba.java:94)
         at prueba.Prueba_jButton1_actionAdapter.actionPerformed(Prueba.java:151)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
         at java.awt.Component.processMouseEvent(Component.java:5501)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
         at java.awt.Component.processEvent(Component.java:5266)
         at java.awt.Container.processEvent(Container.java:1966)
         at java.awt.Component.dispatchEventImpl(Component.java:3968)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1778)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)I will appreciate a lot some help :)
    Thankx

  • How to Run a simple program using JMS Queue.!!

    Hi All,
    I am trying to run simple program on JMS Queue.
    Using SOA Suite 10.1.3.2
    I created a connection factory and queue using EM.
    Connection Factory => Domain : Queue JNDI Location : jms/sidConnectionFactory
    Queue Name : SidQueue JNDI Location : jms/SidQueue
    Tried running a simple java class to send the messages to queue.[Pls find the file attached].
    Getting this error
    javax.naming.NamingException: META-INF/application-client.xml not found (see J2EE spec, application-client chapter for requirements and format of the file)
    at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getRequiredClasspathResource(ApplicationClientInitialContextFactory.java:239)
    at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getArchive(ApplicationClientInitialContextFactory.java:161)
    at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:111)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    Can some one tell me how i need to create this file and where to place this[i.e is this need to be placed in  my project or some directory structure of <SOA-HOME>
    Thx,
    Siddhardha.
    Code:
    package demo;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Properties;
    import javax.jms.*;
    import javax.naming.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class JMSQueue {
        public static void main(String args[])
    QueueConnection queueConnection;
    QueueSession queueSession;
    //private MessageProducer producer;
    QueueSender queueSender;
    try {          
    String message = "Test";
    String connectionFactoryName = "jms/sidConnectionFactory";
    String destinationName = "jms/SidQueue";
    /*Do i need to use this .......
    * If so where is the error in below statements...
    * Properties env = new Properties( );
    // ... specify the JNDI properties specific to the vendor
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "welcome");
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.evermind.server.ApplicationClientInitialContextFactory");
    env.put(Context.PROVIDER_URL,
    "ormi://localhost:23791");
    Context ctx = new InitialContext();
    // Get the connection factory.
    QueueConnectionFactory cf = (QueueConnectionFactory)ctx.lookup(connectionFactoryName);
    // Get the destination.
    Queue destination = (Queue) ctx.lookup(destinationName);
    // Use the connection factory to create a connection.
    queueConnection = cf.createQueueConnection();
    // Start the connection.
    queueConnection.start();
    // Use the connection to create a session.
    queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    // Use the session and destination to create a message producer and a message consumer.
    //producer = queueSession.createProducer(destination);
    queueSender = queueSession.createSender(destination);
    TextMessage msg = queueSession.createTextMessage(message);
    queueSender.send(msg);
    queueSession.close();
    queueConnection.close();
    catch (Exception ex) {
    ex.printStackTrace();
    * Attached following libraries to the Project
    * jms.jar
    * optic.jar
    * oc4jclient.jar
    */

    Hi,
    You need to change the INITIAL_CONTEXT_FACTORY to com.evermind.server.RMIInitialContextFactory.
    Regards,
    Sandeep

  • Run a simple servlet in WLS6.1

              Hi,
              I am new to WLS 6.1
              I have a simple servlet that outputs a string on webpage.
              I am trying to run this servlet using the WLS6.1
              I have compiled the source code and copied the class file (MyFirstServlet.class)
              into
              D:\BEA\wlserver6.1\config\mydomain\applications\DefaultWebApp\WEB-INF\classes
              I have the web.xml file in web-inf directory as below
              <?xml version="1.0" ?>
              <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 1.2//EN"
              "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
              <web-app>
              <servlet>
                   <servlet-name> HelloWorld </servlet-name>
                   <servlet-class> HelloWorld</servlet-class>
              </servlet>
              <servlet-mapping>
                   <servlet-name> HelloWorld </servlet-name>
                   <url-pattern> HelloWorld </url-pattern>
              </servlet-mapping>
              <welcome-file-list>
              <welcome-file>index.html</welcome-file>
              </welcome-file-list>
              <servlet> <servlet-name> MyFirstServlet </servlet-name> <servlet-class> MyFirstServlet
              </servlet-class> </servlet>
              <servlet-mapping> <servlet-name> MyFirstServlet </servlet-name> <url-pattern>
              MyFirstServlet </url-pattern> </servlet-mapping>
              </web-app>
              HelloWorls is also another simple servlet.
              then in the browser I give
              http://localhost:7001/MyFirstServlet
              this is the error I get
              Error 404--Not Found
              From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
              10.4.5 404 Not Found
              The server has not found anything matching the Request-URI. No indication is given
              of whether the condition is temporary or permanent.
              If the server does not wish to make this information available to the client,
              the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code
              SHOULD be used if the server knows, through some internally configurable mechanism,
              that an old resource is permanently unavailable and has no forwarding address.
              what is the problem?
              Please anyone help me in this matter!
              Thanks in Advance
              SP
              

              Hi,
              I am new to WLS 6.1
              I have a simple servlet that outputs a string on webpage.
              I am trying to run this servlet using the WLS6.1
              I have compiled the source code and copied the class file (MyFirstServlet.class)
              into
              D:\BEA\wlserver6.1\config\mydomain\applications\DefaultWebApp\WEB-INF\classes
              I have the web.xml file in web-inf directory as below
              <?xml version="1.0" ?>
              <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 1.2//EN"
              "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
              <web-app>
              <servlet>
                   <servlet-name> HelloWorld </servlet-name>
                   <servlet-class> HelloWorld</servlet-class>
              </servlet>
              <servlet-mapping>
                   <servlet-name> HelloWorld </servlet-name>
                   <url-pattern> HelloWorld </url-pattern>
              </servlet-mapping>
              <welcome-file-list>
              <welcome-file>index.html</welcome-file>
              </welcome-file-list>
              <servlet> <servlet-name> MyFirstServlet </servlet-name> <servlet-class> MyFirstServlet
              </servlet-class> </servlet>
              <servlet-mapping> <servlet-name> MyFirstServlet </servlet-name> <url-pattern>
              MyFirstServlet </url-pattern> </servlet-mapping>
              </web-app>
              HelloWorls is also another simple servlet.
              then in the browser I give
              http://localhost:7001/MyFirstServlet
              this is the error I get
              Error 404--Not Found
              From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
              10.4.5 404 Not Found
              The server has not found anything matching the Request-URI. No indication is given
              of whether the condition is temporary or permanent.
              If the server does not wish to make this information available to the client,
              the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code
              SHOULD be used if the server knows, through some internally configurable mechanism,
              that an old resource is permanently unavailable and has no forwarding address.
              what is the problem?
              Please anyone help me in this matter!
              Thanks in Advance
              SP
              

  • How to run... HelloWorld & simulate it..?

    Hello,
    I have installed JCDK2.1.2. I have conpiled HelloWorld.java file . It compiled without any error. Now wat is the next step. How do i simulate it. How to run the file. How to upload in Smart card ..?
    Please give me some detail description other then wat is specified in JCDK2.1.2 doccumentation user guide.
    Thanking You,
    Mehul

    After compiling, you have to generate the cap file, scr file and app file. But cap file is enough to upload into the card. To do it we need a special software which is available in the card manufacturers.

  • How to run BW reports since BI JAVA is not available in 7.4.

    We have Upgrade our BW 7.0 to BW 7.4 on HANA, How to run our BW reports since BI JAVA is not available in 7.4.
    My scenario: Producer Portal (BW portal ) we are creating/marinating Portal objects ( Folders, roles, work sets ……etc.), which replicate in Consumer portal (EP portal) via Federation framework. In-fact its abstraction layer, not hosting any Portal content physically but giving a unified enterprise access to business.  The actual content and execution of users requests occur on Producer portal itself.
    We have to maintain two portal in this case (consumer & producer).
    In BW 7.4 version,  dual stock is no longer supported. In order to maintain the federation paradigm have to purchase new license & servers for java stack.  What about if we directly integrate our BW reports in EP portal ? what would be draw back or issues in this approach in terms of durability, maintenance administration efforts……….etc . Please suggest us the best design solution for me.  Need expert opinion.
    Now it looks like extra layer (Standalone JAVA stack) to maintain & host?  Agree or no?
    Is federation still have worth or have some else new SAP concept. ?
    Thx,
    Jameel

    Hi Nawab,
    1
    Of course, do additional users and activity also consume ressources of the EP 'machine'.
    If you'll run in performance leak, is depending on the special situation. And of course the AS Java can be tuned/optimized for higher workload.
    Maybe if you are on a virutualized environment, it's easily possible to increase the ressources of the machine/s - or its possible to add additional java-nodes on separate servers...
    Lots of possibilities to increase the workload-power if needed...
    From my personal opinion, I usually recommend a separate BI-Java instance - not shared with other funcitonality.
    2
    Not sure if I get you right.
    There are two technical options to run a ABAP+JAVA Stack on one server.
    In one SAP instance - then ABAP and java processes are controlled in one framework. --> This option is not possible any more under 7.4
    in separate SAP instances - then the two SAP systems are running on same host but each has its on framework/instance running. It is similar to running on separte servers.
    Licensing:
    From an SAP view, there is no additional licensing cost for the separte Java Stack!
    But for sure, if you set it up on a separate server you may have additional cost for OS licensing, VMware, etc. - depending on your infrastructure...
    My recommend, if you plan to move with that stuff to HANA:
    Assuming you have 2-system landscape - DEV and PRD.
    Assuming you are in a virtual environment like vmware.
    Currentently you have two servers - on each a DualStack BW incl. current database on it.
    1. Set up four new machines with half sizing as you currently have.
    2. Split the DualStack and run the two new Java stacks on the new servers.
    3. Migrate your BW ABAP to HANA
         Set up the ABAP Application servers for your BWonHANA on the other two new servers.
    4. Kill/Recycle the two now free servers.
    Regards,
    Stefan

  • How to run a simple program with main?

    I have a simple class with main, something like the following:
    public static void main(String[] args) {
    Is it possible to run / execute this main from within workshop?

    In SP2 we've made it very easy to automatically set the main class name
    when you first try to run a class in a Java project that doesn't have
    already have debugging configured.
    More generalized ways to easily run a class with a main method are
    already on the list for the next release.
    Thanks for the feedback,
    Josh
    Carl wrote:
    Thanks, that worked:)
    Workshop should consider dealing with simple classes with main much
    simpler...
    "Josh Eckels" <[email protected]> wrote in message
    news:3f96f8c1$[email protected]..
    Yes, you can run and debug it, but it needs to be in a Java project. If
    it's not already in one, create a new Java project and copy in the
    source. Go to the Project Properties, and select the Debugger settings.
    Enter the class that contains the main method. If you'd like, you can
    set the checkbox for Build before Debugging so that you are always
    running off the current source code.
    You should then be able to run the project after building it.
    Josh
    Carl wrote:
    I have a simple class with main, something like the following:
    public static void main(String[] args) {
    Is it possible to run / execute this main from within workshop?

  • How to run unix shell script from java web applet

    hi all
    i have created one java applet. my apache web server is on unix server.
    i have created one shell script in same directory where my .class and .htm files reside...
    how to run this shell script from applet? it should search this .sh file on server and not on the client browser machine...
    thanks in advance

    I suppose you could make the shell script into a CGI, configure the server to execute CGIs, and then make the applet open the URL of that CGI.

  • How to run jsp and servlet using JBOSS server

    Dear Friend,
    I have JBoss application server and Eclipse id
    now i want to run JSP and Servlet but i am not getting the place where to place my servlet class file to run it .
    before that i run jsp and servlet using tomcat5.0 but in that i place my servlet class in WEB-INF/classes folder and do corresponding entry in web.xml file and run it through browser.
    now i want to use JBOSS how it is possible
    PLZ Help me

    Is the servlet class defined in a package.? If servlet class package is servlets., copy the servlet to
    WEB-INF/classes/servlets directory.

  • How to deploy a simple servlet in EP?

    Hi,
    I am new to this portal.
    Is it possible to deploy a simple servlet which extends a HttpServlet?if yes what modification i need to make for the portalapp.xml?
    Thanks
    Deepak

    hi deepak,
       it is possible to deploy servlets in AbstratPortalComponent.
      check this link ..
      http://help.sap.com/saphelp_nw2004s/helpdata/en/0a/fd2c41cf358839e10000000a1550b0/frameset.htm
       you will find example in this thread .
    thanks..
    rajesh

Maybe you are looking for