Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: new at JavaEE

  1. #21
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: new at JavaEE

    Ok lots of new things to learn....
    I'll leave the JSP stuff aside for the moment and concentrate on the servlet, right!
    At first I am looking into that mysterious web.xml file:
    So I created a folder at webapps called hellworld and created, inside hellworld:
    "WEB-INF" which contains the folder "classes" (webapps/hellworld/WEB_INF/classes)
    -inside WEB-INF one finds also the file: web.xml
    -inside classes one finds: HellWorld.class

    First the web.xml
    <web-app>
    <servlet>
    <servlet-name>hworld</servlet-name>
    <servlet-class>HellWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>hworld</servlet-name>
    <url-pattern>/baba</url-pattern>
    </servlet-mapping>
    </web-app>

    1) the"hworld" is there "just" to identify the mapping, right?
    2) when <url-pattern> is simply "/HellWorld" than the servlet start up like this:
    http://localhost:8080/hellworld/HellWorld
    3) when it is baba, like above the start up is:
    http://localhost:8080/hellworld/baba

    https://jcp.org/aboutJava/communityp...315/index.html

    So the trouble with the previous code has to to when stuff starts to interact, right?
    (will the oracle throw me another clue pls.......)

    Java Code:
    import java.io.*; 
    import javax.servlet.*; 
    import javax.servlet.http.*;
    
    // Extend HttpServlet class
    public class HellWorld extends HttpServlet{
    	private String message;
    	public void init() throws ServletException { 
    		// Do required initialization
    		message ="let the books of JSP burn in hell!";
    	}
    
    	public void doGet(HttpServletRequest request, HttpServletResponse response) 	
    								throws ServletException, IOException {
    		// Set response content type
    		response.setContentType("text/html");
    		// Actual logic goes here.
    		PrintWriter out= response.getWriter(); 
    		out.println("<h1>"+ message +"</h1>"); }
    
    	public void destroy() { 
    		// do nothing. 
    	}
    }
    Last edited by willemjav; 04-03-2014 at 05:39 PM.

  2. #22
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,260
    Rep Power
    6

    Default Re: new at JavaEE

    A clue about what? You're on the right track, are you having troubles? I can't read your mind!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #23
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: new at JavaEE

    "A clue about what?"

    "So the trouble with the previous code has to to when stuff starts to interact, right?"
    what to say for instance: /ebookshop or /ebookshop/eshop at line 40 and 91 #4
    and what about #3 line 21 (first) and line 42 (second)

  4. #24
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,260
    Rep Power
    6

    Default Re: new at JavaEE

    I would very much recommend you to forget your previous code exists. Study from the beginning and with your new-found knowledge, start from scratch and this time write code you understand.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #25
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: new at JavaEE

    Quote Originally Posted by willemjav View Post
    At first I am looking into that mysterious web.xml file:
    The one thing the web.xml should not be, if you are trying to learn the stuff you seem to be trying to learn, is "mysterious".
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #26
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: new at JavaEE

    I am starting up several servlet examples and I am using the web.xml to map each one!
    So things are getting a lot clearer now!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Best IDE for JavaEE development.
    By chyrl in forum Advanced Java
    Replies: 7
    Last Post: 01-26-2013, 03:17 PM
  2. Public folder in JavaEE webapp
    By Vash1986 in forum Java Servlet
    Replies: 0
    Last Post: 11-15-2011, 11:44 PM
  3. Replies: 2
    Last Post: 03-10-2011, 10:25 AM
  4. Netbeans 6.9.1 JavaEE Framework
    By chyrl in forum Web Frameworks
    Replies: 0
    Last Post: 11-07-2010, 07:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •