This question already has an answer here:
Using .html files as JSPs
(1 answer)
Closed 8 years ago.
OS: Windows Server 2008 R2 SP1
Web Server Front-End: IIS 7.5
Web Server Back-End: Tomcat 5.5
AJP Connector is used to pass JSP content from IIS to Tomcat.
I have a number of project folders that get delivered for web consumption every so often. The web pages themselves end with the HTML extension. They need to be hosted on a Tomcat web server and I need session management control via a JSP application. That is, it's not enough for me to check if the session is active for Tomcat. I have some session control specific to the JSP application itself.
I suppose I could run a script which takes the multitude of HTML pages and converts them into JSP, but I'd like to keep things as "drag-and-drop" friendly as I can. I'd rather not make any changes directly to these project folders.
Is there a way I can enforce Tomcat to treat HTML pages as JSP pages? I.e., If, for example, I wanted to include JSP expressions inside the HTML pages, I could do that.
Thank you very much for any help.
Jsp pages are similar to html pages they are actually scripts included inside html pages, they are written in between <html></html> tag
so you can access jsp pages as html
Just save those pages with.html extension
Related
I'm researching using JSP for a project that could be accessed locally and over the web. That is, I would be creating the project in JSP and would like to generate a kind of setup.exe that the client would run to set up the environment to run the JSP in their browser. For example, if I were to choose Tomcat, do I create a setup program that also installs Tomcat and then stores the JSP application in the proper directory? More specially, for those in the industry that program JSP professionally, how does your company deploy a JSP application to the client? If you host the JSP application on your server what about a solution where the client hosts a local server so they can run the application locally on their machine? Is that possible?
I think you have some confusion. In a JSP-based application (note that that technology is very old and you should use JSF instead) there are two sides: the server side and the client side.
The server side has Tomcat or any other Web Application Server that
deploys the JSPs as you said.
The client side just needs a browser (e.g. Mozilla, Chrome, Lynx,
etc) to access the JSP-based application via Web.
In other words, you don't deploy in client machines. You just deploy in the server and your clients access your application with, normally, a Web browser.
Further reading:
Java JSP, JSF and JS.
Difference between JSF sevlet and JSP
I am developing a JSF application and the archive (war) will be given to multiple customers and will be separately deployed on their own Tomcat servers. This is just a front end application and it uses web services to communicate with a remote server.
In my JSF application, some tabs and panels are conditionally rendered according to the ORG_ID and Roles of the logged in user. All these restrictions are written in .xhtml pages as ELs:
<rich:tab header="Registration" rendered="#{permissionController.hasSuperRole()}"/>
Since this application is deployed in customers premises, they can edit the .xhtml files and remove these restrictions. Is there a way to overcome this issue by encrypting xhtml files, checking last modified date...?
This issue is totally not related to java jsf or (x)html. It is the generic issue that you should never trust the client (like you never should in e.g. a webapplication where a user can manipulate the html/javascript in the browser)
Solution: Just do additional authorization in the webservices.
For performance testing & monitoring, I would like to add a JavaScript in the header tag of a web pages. All pages comes from a Java application running on Tomcat 7.
Is that possible? If yes, how do I do that?
Do JAVA apps have to run on JSP? Are there other ways the app can be interpreted on the client side?
Clients (assuming you mean browsers like Firefox, IE etc.,) can understand HTML and Javascript only. Your JSP code will be executed on server and respective HTML code will be sent to browsers.
There are lot of alternatives like JSF, HTML etc., are available. I would suggest reading this tutorial.
JSP is a technology that runs on the server side and produces a response that will typically be viewed in a web browser. There are many other ways to do the same, including Java servlets, JSF, etc.
Java can run on the client side either as an application (i.e. the user downloads a file and runs it locally), or as an applet (which runs in the web browser).
if the top of your JSP reads
<%# page contentType="application/x-java-jnlp-file"%>
<?xml version="1.0" encoding="UTF-8"?>
How do you add html to this page?
Equally, How would you get the web browser to create a popup for instructions?
How do you add html to this page?
If you do, it won't be a JNLP file. It will be a mess that is pretending (poorly) to be a JNLP. Most JWS clients would reject it, pointing out that it is not JNLP, the rest would fail with other (less obvious) errors.
Equally, How would you get the web browser to create a popup for instructions?
Aaaargh, the dreaded pop-ups. My browser would kill them automatically.
Put instructions on the page that links to the JSP that launches the app.
Why not write a regular servlet for it? JNLP files are not html and i dont even know how that would work with JSP.
And if you send a JNLP most web browsers will know what to do with it, you can also distribute this file through email(or other means) and start it directly on the users computer.
I used to have several WebStart apps a few years ago and i wrote a servlet that would just serve the JNLP file from the local file system. I later changed it to generate the JNLP file on the fly and include default libraries i used in all my projects. I also used that to serve the jars from the file system so they didnt need to be bundled with the servlet WAR.
I put some of my code here http://ideone.com/36sjB as a start. Most of it was used in an experimental in house app, so this should not be used in production code ;).
Sending the JNLP is just like sending the jar with a different content type. I also have code about generating the JNLP from scratch through the servlet if you are interested.