guardmed Posted December 19, 2012 Posted December 19, 2012 Hello,I have an account on Jhonny with java enabled.JSP is working fine but Servlets just won't work. I tried the most basic class I could find:import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("<HTML>"); out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>"); out.println("<BODY>"); out.println("<H1>Hello World</H1>"); out.println("Today is: " + (new java.util.Date().toString()) ); out.println("</BODY></HTML>"); } // doGet } // HelloWorldAnd compiled it. I uploaded it to /public_html/WebContent/WEB-INF/classes and added the needed info to web.xml. I could not reach the servlet HelloWorld.I uploaded it to /public_html/WEB-INF/classes and added the needed info to web.xml. I still could not reach the servlet HelloWorld. I tried any combination I could think of in order to get this servlet to work, but nothing did the trick.If anyone knows or has been able to activate the servlets, here are my three questions:Where did you put the compiled servlet class?Where did you put the "web.xml" (I know, in the WEB-INF, but there are two)?How did you do the servlet mapping in the "web.xml" (using the .class in the path or not)?What URL did you use to reach the servlet (with starting from the <name>.heliohost.org/)?I tried any combination I could think of but nothing did the trick. Thank
Krydos Posted December 23, 2012 Posted December 23, 2012 If anyone knows or has been able to activate the servlets, here are my three questions:Since you prefaced your questions with this condition I figured you wanted someone to respond who knows what they are talking about. I'll be the first to admit that I have no clue what I'm talking about so I abstained from commenting.Where did you put the compiled servlet class?No clue.Where did you put the "web.xml" (I know, in the WEB-INF, but there are two)?Don't know the answer to that either.How did you do the servlet mapping in the "web.xml" (using the .class in the path or not)?Beats me.What URL did you use to reach the servlet (with starting from the .heliohost.org/)? I tried any combination I could think of but nothing did the trick.Probably guardmed.heliohost.org/appname, but that's just a guess.Anyone? Anything? Please?Ah yes, now I qualify! How about this: If you can create me a .war file of your servlet and upload it to /home/guardmed I can play around with it and see if I can get it to work. No promises though, because I've never done any of this stuff either. Just let me know once it's uploaded.
guardmed Posted December 25, 2012 Author Posted December 25, 2012 Thank you Krydos I deleted all files from the account (jsp, class, xml, images. everything).I uploaded HelloWorld.war.The reason I did not do so in the first place is because of the following thread - http://www.helionet.org/index/topic/11272-deploying-war-file-java-application/page__hl__%2Bservlet+%2Bfile__fromsearch__1 Information about this war file:The website name is HelloWorld - in my system I actually use http://localhost:8080/HelloWorld/ So I assume on the heliohost server it should be something like guardmed.heliohost.org/HelloWorldThere is one JSP in the war, it's named Hello.jsp. This is actually reachable using the url http://guardmed.heliohost.org/HelloWorld/Hello.jspThere is one servlet in the war, it's named HelloWorld. Could not reach it any wayThere is a web.xml with the following needed informationThe welcome page is defined to be Hello.jsp, meaning that the url http://guardmed.heliohost.org/HelloWorld/ should go directly to http://guardmed.heliohost.org/HelloWorld/Hello.jsp For some reason right now this doesn't happen. It does happen on my system.There is a servlet mapping for HelloWorld to /HelloWorld. So I would expect http://guardmed.heliohost.org/HelloWorld/HelloWorld to go the servlet (but it doesn't). It's interesting to see that the tomcat does open the war, because it opens the jsp when called directly. Any help would be appreciated
guardmed Posted December 27, 2012 Author Posted December 27, 2012 I tried using my local installation of tomcat and run this war.It works on my machine.http://localhost:8080/HelloWorld/Hello.jsp worksSince the above is defined as the welcome page I also get it when using http://localhost:8080/HelloWorld/Finally, the servlet works. I can reach it using http://localhost:8080/HelloWorld/HelloWorldI still don't understand why neither the servlet nor the welcome page definition work on the heliohost server.
Krydos Posted December 27, 2012 Posted December 27, 2012 How does this look? http://guardmed.heliohost.org/HelloWorld/ Sorry for the delay; was busy with the holidays.
Shinryuu Posted December 28, 2012 Posted December 28, 2012 Also here's a screenie of your servlet since that was what interested you.
guardmed Posted December 29, 2012 Author Posted December 29, 2012 How does this look? http://guardmed.heliohost.org/HelloWorld/ Sorry for the delay; was busy with the holidays. Thank you Krydos, this is impressive.I would like to know how you were able to make it work (as the "HelloWorld" project isn't really the goal I'm trying to achieve). One thing is a mystery to me.The welcome page works - it goes to Hello.jps like it should - http://guardmed.heliohost.org/HelloWorld/The servlet works - like Shineryuu showed in the screenshot - http://guardmed.heliohost.org/HelloWorld/HelloWorldDirectly accessing the jsp no longer works - it originally worked, but now no longer does - http://guardmed.heliohost.org/HelloWorld/Hello.jspI don't understand how using the direct url no longer works. More interesting, the jsp can be reached using the welcome page, but not directly. So I'm guessing something probably changed with the url address. I wonder what. Thank you and happy holidays, whichever they may be.
Krydos Posted December 31, 2012 Posted December 31, 2012 I would like to know how you were able to make it work (as the "HelloWorld" project isn't really the goal I'm trying to achieve).I made it work because I have more access as an administrator than a regular user does. While it is possible to deploy WAR files on HelioHost, it would require additional configuration by the administrators.I'm considering setting up an automated way for Johnny accounts with java enabled to deploy their own .war files, but for now users can just drop their .war in their home directory like /home/username/Project.war and I can deploy it for them.
Recommended Posts