简体   繁体   中英

deploying a static html on glassfish

I am new to java-ee, so my question might appear naive. I have created an ejb and deployed it on glassfish. The servlet program calls methods in the ejb. Then, in order to test the ejb, I created a servlet and also deployed it on glassfish. Now, in order to send values to the servlet, I have a client static html. I am not sure how I go about deploying and invoking this html on my glassfish server. Any help will be much appreciated.

Follow up information- @Akhilless, thank you for your detailed answer- but I still have some questions. I am using Eclipse. Below is a picture of my servlet project. This servlet invokes an EJB (not shown). In the servlet project shown in the picture, you can see the static html file 'GetTickerInfo.html'. This html file calls the servlet, which in turn calls the EJB.

I have deployed both the EJB and the servlet projects on glassfish. Now my problem is that I am unable to invoke the html- I am not sure what the correct url is. Will much appreciate it if you can explain to me how to find the context root etc., and how to find the correct url in the current situation. Thanks.

在此处输入图片说明

I guess that you use WAR packaging. All the static files go directly in the assembly root of the package. So that if your WAR file is named myapp.war and your static file is named static.xhtml , the WAR archive's structure looks like this.

myapp.war
    ---- static.xhtml
    ---- WEB-INF
    ---- ---- web.xml
    ---- ---- lib  
    ---- ---- classes

A nice graphical depiction of the WAR file's structure is provided in the Java EE documentation

WAR档案的结构

Where your put your static files in the source code depends on the IDE and build management tools you use. If you use Maven, then the static files will go into the webapp folder so that your project's structure looks like this:

mywarproject
    ---- src
    ---- ---- main
    ---- ---- ---- java
    ---- ---- ---- resources
    ---- ---- ---- webapp
    ---- ---- ---- ---- static.xhtml
    ---- ---- ---- ---- WEB-INF
    ---- ---- ---- ---- ---- web.xml

which graphically looks like this

Maven项目结构

Here the static file is Sample.html .

You do not invoke any static files on Glassfish - static files are just opened by typing their address in the address bar. For example, if your file is named static.xhtml and your application's context path is /myapp , then you can open it after deployment on a local Glassfish by typing http://localhost:8080/myapp/static.xhml .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM