I have a java web application project in netbeans. I would like to know how to include the bootstrap framework in this project. It is important that the project works without using Internet access.
Just download the Bootstrap file from getbootstrap.com and unzip it into your assets folder. Where this folder is depends on the structure of the framework you are using or even if you are using some framework. Then just add Bootstrap CSS and Javascript files to your pages. Then again, the correct way to do this depends on the framework you are using. If you are using JSF2, for instance, add these files to your template(s) and they will load when needed.
Related
I added all the jar files of application insight sdk for java in java web project and included the code for sending custom telemetry in servlet but when i try to run the servlet it shows classnotfound error for TelemetryConfiguration and TelemetryClient.
Per my experience, I think you can try to check the jar files of Application Insight SDK for Java whether be added the Libraries of Java Build Path, please right click the prject name and select the Properties in the menu.
If using Maven project, you can see the jar files in the Maven Dependencies.
If using the normal Dynamic Web Project, you can see them in the Web App Libraries or a User Library with custom name.
Then you need to try to manually build the project, and run the servlet again.
It seems that you added only the web library without the core library, which contains the TelemetryClient class.
You can read the Application Insights Java SDK article which describes in details how to add the Java SDK to your web project, whether you're using Maven or Gradle as your build system, or manually downloading and referencing the libraries.
I have a Maven Web Application with Spring MVC and I need to convert it into a Java Web Application build with Ant. I am using Netbeans. The path structure should be the same? What configuration files should I add, remove, or change?
The reason of the change is beacuse I need to run the application without Internet connection.
I'm developing a simple maven web application using angular and java inside a same project.For front-end I use webapp/resources as the path.The problem was when I edit some javascipt/css or other static resources then I have to re-deploy the whole application.Is there a way to deploy only web files instead of re-deploying the whole app.I'm using 'tomcat7-maven-plugin' for building purpose.
thanks.
I wanna develop a small Framework to help us on reusability. It will have some Java components to handle Permissions, DAO, Logging, etc, and some Servlet components for handling Authentication, request parameters, etc. And also JSPs with HTML snippets, header, footer, CSS, JS, etc etc.
What I can't find out, is how to deploy this Framework as a jar lib, to be consumed by other applications. Where should WebContent, JSP, etc should be, and how to export it in Eclipse.
Where should WebContent, JSP, etc should be
In /META-INF/resources folder of the Java source folder. Just create one if it doesn't already exist.
and how to export it in Eclipse
Just as JAR into /WEB-INF/lib of a web project. You can let Eclipse automatically do that by specifying the shared project in Deployment Assembly of the dynamic web project.
You can also create the shared project from the beginning on as Web Fragment Project. It'll prepare the folder structure for you and automatically be added as Deployment Assembly of an existing project.
See also:
How do I include a JSP file from a different project into my project
I have a Java Project, for which I'm now creating a Web interface, using a Dynamic Web Project from Eclipse. The Web project consists of a single servlet and two JSP's. Something like this:
/JavaApplication
/src
/lib
/resources
/WebApplication
/src
/Servlet.java
/WebContent
/WEB-INF
index.jsp
other.jsp
Now, I need to reference JavaApplication from WebApplication, in order to use its classes to process web requests. What's the best way to accomplish this ? My idea is to create a .jar of the JavaApplication, containing all the .class files, /resources, and /libs. In this way, I could include the .jar in the web application, and I could have a single .war file that contained the entire application.
What do you think? How is this problem typically solved ?
Note: I don't want to convert the Java Project into a Web project.
In Eclipse project properties, add the project to the Java EE Module Dependencies (Eclipse 3.5 or older)
or Deployment Assembly (Eclipse 3.6 or newer) entry in the project properties.
This way Eclipse will take care about doing the right thing to create a WAR out of this all (it will end in /WEB-INF/lib). No other configuration is necessary, even not some fiddling in Build Path.
Under Eclipse, you can declare Project References for a given project, the web application in your case. To do so, right click on your web application project, then go for Properties > Project References and select the JavaApplication project. This should allow you to call code from the JavaApplication project from the WebApplication without having to build a WAR. This is a solution for development.
For standard deployment (outside the IDE), you should indeed create a standard WAR. To do so, you'll have to package your JavaApplication as a JAR including the .class files and the files under /resources but not the libraries it depends on (JARs under /lib). These dependencies will actually end up in the WEB-INF/lib directory of the WAR, beside the JAR of your JavaApplication. These steps are typically automated with tools like Ant or Maven.
Connecting java app to web app for development :
right click on web project :
properties>project references> add the java project you want to refer
Now in properties tab of web project go to
properties>deployment assembly> add the project manually and run the app
Consider moving up to EAR level, if your web container supports that.
The tricky part with shared code is where should the common code be put. A copy pr web application? A copy in the web container? Overdoing the "share these classes" might end up in class loader problems.
If you are creating two separate web applications refactor common java code into a separate Eclipse project and refer to it from both WAR projects.
EDIT: Apparently I have misread the problem description, and thought you asked about an existing and a new web application sharing code.
If you have an Eclipse project with your application, and another with your web frontend, then you can let your application export the necessary resources which the "Export WAR" in Eclipse Java EE can wrap up in a jar file and put in WEB-INF/lib for you. You need to say this explicitly with a checkmark in Properties -> Java EE Module Dependencies for your web project. Expect you have to experiment a bit - this took me a while to learn.
Typically you would create an API interface using remote service beans from the Java application that expose the methods that you want to invoke in the web application. You would include a proxy of the API interface with your web application that calls the remote service bean in the Java application. Remember that you will need to register the remote bean in the web.xml file.