I was hoping to get some advice on what to do. I have a .war file containing RESTful calls that I got to work by deploying them using jBoss 5. I want to host a simple html file in the same local domain (localhost:8080) to make a sample rest call using jQuery.ajax(). Should I download Apache to host these files in localhost:8080? Thanks for helping me out.
By Apache I am assuming you mean Apache Web Server or Apache Httpd. In that case, no you do not need apache for hosting an HTML file. You can package the html files along with the javascript and images files in your war.
Here is a sample of how your war can be packaged.
webapp.war
|
|---> WEB-INF
| |----> web.xml
| |----> classes
| |----> MyResource.properties
| |----> RestfulService.class
|---> index.html
|---> javascript
| |---> jQuery.js
|---> images
| |---> logo.gif
Hope this helps.
Good luck!
Related
I have a wildfly-14.0.1.Final server and a project (foodHosting) with a deployable ear module named foodHosting-ear and a web war module named fooHosting-web. After the deploy to reach my index.xhtml I have to write localhost:8080/foodHosting-web/ to my browser. Is there any solution to write only localhost:8080 and show my application? Like localhost:8080/index.xhtml?
You have to rename the fooHosting-web.war to ROOT.war
Edit: It's not needed to rename the .war inside your .ear, you have to change the context-root as the answer #wirnse said in the comment, but instead of /WEB-INF/jboss-web.xml check your /META-INF/application.xml and empty the context-root tag: <context-root></context-root>
In Eclipse, the folder structure when I create a Dynamic Web Project is
.: build src WebContent
./build: classes
./build/classes:
./src:
./WebContent: index.html META-INF scripts WEB-INF
./WebContent/META-INF: MANIFEST.MF
./WebContent/scripts: jquery-1.7.1.js
./WebContent/WEB-INF: lib web.xml
./WebContent/WEB-INF/lib:
As you can see, there is WebContent directory containg web-inf and other files, if I moved all the directories and files of WebContent directory a level above, it does not work, what to do to run the index.html in eclipse
-> the directory structure after moving all the directories and files of WebContent directory a level above:
.: build index.html META-INF scripts src WEB-INF
./build: classes
./build/classes:
./META-INF: MANIFEST.MF
./scripts: jquery-1.7.1.js
./src:
./WEB-INF: lib web.xml
./WEB-INF/lib:
So, now I need just go to "http://localhost:8080/Sample" and should go to index.html properly what path changes need to be done to make it run?
I am not sure what you mean by "what to do to run the index.html in eclipse" and what you are referring to by "sample" in the URL that you provided, but here are some thoughts:
as a part of JavaEE specification, you must follow a specific directory structure and you can't fight it. For more info:
http://docs.oracle.com/javaee/6/tutorial/doc/gexap.html
In other words, you can call "webContent" whatever name you want, but you can't move it's content outside of that directory. Web-INF and your pages must be in a directory (of whatever you want to call it)
If your concern is to simply get to index.html from "http://localhost:8080/Sample", then you can do so by configuring web.xml and context root of your application as such:
In your web.xml file (inside your Web):
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
In your application.xml file (inside your EAR):
<web>
<web-uri>YourWebModule.war</web-uri>
<context-root>sample</context-root>
</web>
Then pinging servername:port/sample will redirect you to servername:port/sample/index.html
hope I addressed the question correctly
I am new to developing on JSF (and new to web development in general) and I am trying to put an image on a page.
I'm developing my JSF app in Eclipse and running it on Glassfish 3.1.2. I have registered Glassfish as a server in Eclipse, and running the app via Eclipse.
I use the following markup on my xhtml page:
<h:graphicImage library="images" name="logo.png"/>
I copied the image in META-INF/resources/images/logo.png .
The image does not appear on the page and when I view the page source I see the element
<img src="RES_NOT_FOUND" />
indicating that the image is not found.
When I export my app to a war file and deploy it onto Glassfish via the autodeploy folder, I get the same results - the page displays, but the image does not appear.
Can anyone advise why the image resource is not found?
I copied the image in META-INF/resources/images/logo.png
This location will only work if the project represents a standalone module JAR which ultimately ends up in /WEB-INF/lib of the WAR.
This does not seem to the case in your particular case. Nothing in your question indicates that you're indeed developing a module JAR file. Apparently you've placed it straight in the WAR this way. This is not right.
You need to put the /resources folder straight in the public web content, not in the META-INF folder.
WebContent
|-- META-INF
|-- WEB-INF
| |-- faces-config.xml
| `-- web.xml
|-- resources
| `-- images
| `-- logo.png
`-- index.xhtml
See also:
Structure for multiple JSF projects with shared code
Why some resource files are put under META-INF directory
Unrelated to the concrete problem, using images as library name does not look entirely right. Just use
<h:graphicImage name="images/logo.png"/>
See also:
What is the JSF resource library for and how should it be used?
Is it possible to keep the webcontent separate from the WAR when deploying to JBOSS. The motivation for this is to avoid WAR deployment when there are JSP changes.
For example, we need to keep the jsps and other webcontent (css, images etc) in a folder like /home/jboss/webcontent/ and the server/application when referring to any JSPs/images etc needs pick and translate the jsp files from this location.
Thanks so much in advance.
Regards,
Vinay
I wanted to know one thing. When deploying a GWT application on
the server, lets say an application in which there are client files
Greeting.java(entrypoint), service.java,serviceAsync.java and server
file serviceImpl.java(), only the client files will converted to
javascript. After compilation, I take the war file and place it on the
server, but where to place the server file that is serviceImpl.java???
The war file will also contain a /WEB-INF folder with the web.xml your libs and the other java classes needed for the server side.
So you only need to copy your war file in the proper webapps folder from your server.