Results 1 to 6 of 6
  1. #1
    Dreaming is offline Member
    Join Date
    Oct 2011
    Posts
    49
    Rep Power
    0

    Default From eclipse web project to a website

    I have a student auction site project. I have created my web project using eclipse dynamic web project. I also created a free Weebly account. My question is how can I migrate the resources from my computer to the website. For example, here is my Login Jsp:'
    XML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Homepage</title>
    </head>
    <body>
    <h1>Welcome </h1>
    <body style="background:#80BFFF">
    <form action="LoginServlet"> Username <input type="text" name="un"/><br> 
    Password <input type="password" name="pw"/> <input type="submit" value="submit"> 
    </form> 
    </body>
    </html>
    Now, when I run this in eclipse, it is not a problem, because the LoginServlet is in the same project as the jsp and will be run on the tomcat server, so eclipse knows where LoginServlet is (set from the web.xml file) and calls the servlet accordingly. But when I paste this code in the Weebly page, it needs to know where this LoginServlet is, or I get "Resource not found" error. I was thinking of substituting the Loginservlet with the tomcat link, e,g. http://localhost:8080/AuctionSite/LoginServlet but ...
    the tomcat server is running locally on my computer, so this would not be accessible publicly, or? So I don't know. In short, if you create you eclipse dynamic web project and you are done, how can you then migrate all those various jsps and servlets you created, I mean your entire web dynamic project, to a publicly accessible website?

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default Re: From eclipse web project to a website

    you have to write in your configuration file a few details about each servlet you'd like to use and put it in your classes folder or in a folder configured as "server.classDir" in the web configuration file.

    A typical servlet configuration looks like:
    Java Code:
    servlet.name: myservlet
    servlet.myservlet.className: mypackage.MyServletClass
    servlet.myservlet.url: /mysrvlet

  3. #3
    Dreaming is offline Member
    Join Date
    Oct 2011
    Posts
    49
    Rep Power
    0

    Default Re: From eclipse web project to a website

    I didn't get you. Do you mean like what I did in the web.xml file,

    Java Code:
    <servlet>
        <servlet-name>LoginServlet</servlet-name>
        <servlet-class>packagename.LoginServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>LoginServlet</servlet-name>
        <url-pattern>/LoginServlet</url-pattern>
      </servlet-mapping>
    or you mean something else? My problem is not actually how to configure the servlets and get them to work in Eclipse. Everything is working fine in Eclipse. But when I have done my project and all is well, the result must be accessible from a publicly-accessible website. I want to know how can I move all these resources (servlets, jsp, java classes) that are currently in my eclipse dynamic web project to the internet.

    I mean, now I have:

    XML Code:
    <form action="LoginServlet"> Username <input type="text" name="un"/><br>
    Password <input type="password" name="pw"/> <input type="submit" value="submit">
    </form>
    but if I paste this code in a page where I have a website, say Google site or Weebly or Wordpress, or any other free web-hosting site, and then I click on submit, I will get "Resource not found" because the "LoginServlet" is only there locally on my PC in my eclipse web project and not on the internet.

  4. #4
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default Re: From eclipse web project to a website

    Yes I mean that web.xml file. So you've set that up, all good. Have you set the directory of the class files? Once you move something to another computer (i.e. web hosts) the local file path obviously shouldn't work. If it's defined with a relative path it still might not work on your web host due to access permissions (depending on which folders the servlet has access to - usually only its own and onwards but not upwards).

    Also, you actually need a Java Servlet hosting service to run a servlet off your website (it runs on the Server don't forget!).

    This is usually very expensive for reasons that it costs the hosts more to manage and run.

    If you want it to run from your computer, you need either a Static IP at home (costs extra per month with your ISP) or you can get a Dynamic IP host service like dyn-dns.com

    Then you can refer the website to your home PC for the servlet.
    Last edited by ozzyman; 12-27-2011 at 06:16 AM.

  5. #5
    Dreaming is offline Member
    Join Date
    Oct 2011
    Posts
    49
    Rep Power
    0

    Default Re: From eclipse web project to a website

    OK, at the moment I am using tomcat server in my eclipse. Now if I change the action to the localhost tomcat server, e.g.

    XML Code:
    <form action="http://localhost:8080/SWEAuctionSite/index.jsp"> Username <input type="text" name="un"/><br>
    Password <input type="password" name="pw"/> <input type="submit" value="submit">
    </form>
    that means that this will still run on my PC, right? And so it will only be accessible from my PC and only if it is on?

  6. #6
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default Re: From eclipse web project to a website

    localhost on a web server is the reserved IP address 127.0.0.1 (I think thats the IP) but still on the web server.

    localhost on your computer is the same IP, but on your computer.

    As I said, if you want to do this from your computer you'll need a static IP or try dyn-dns.com its free and it will automatically update your IP on its server everytime it changes so that you can have your own name space e.g. http://mywebsite.dyn-dns.com/ and the web company dyn-dns.com will redirect the visitors to your current IP address, that will reflect your local server at 127.0.0.1

Similar Threads

  1. Creating a project in eclipse from existing project
    By Suraiya in forum New To Java
    Replies: 1
    Last Post: 10-08-2011, 10:14 AM
  2. importing a project in eclipse
    By mahesh_j2ee@yahoo.in in forum Eclipse
    Replies: 2
    Last Post: 03-18-2011, 06:18 AM
  3. First EJB3 Project in Eclipse
    By berlindutza in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 10-04-2010, 06:53 PM
  4. opening project in eclipse
    By keioGirl in forum Eclipse
    Replies: 1
    Last Post: 04-23-2009, 04:09 PM
  5. Eclipse And Project Management
    By Moncleared in forum Advanced Java
    Replies: 0
    Last Post: 02-20-2009, 05:44 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
  •