I have a working servlet code, which processes some command prompt commands and I have an editor code written in html, now I want to add this html file to servlet. How do I do it? tried moving the html file to WEB-INF.
I've looked into this link on How to integrate HTML design into Servlet? but everything seems damn cumbersome as I have a very large html file.
Any other fixes?
If your editor.html contains only static JS, CSS and HTML (you don't depend on the data provided by your servlet), you can simply forward your servlet into JSP and include your html page from it using
<%# include file="editor.html" %>
Related
I made some kind of internal manual for a webapp that i am developing. I am using Spring Boot and Vaadin 14. How to implement a button that shows that document? The html doc is in my resources folder. I wonder if i am stupid. Or should i write my own controller for this?
A Vaadin application itself is a single dynamic HTML page.
The easiest way to include HTML formatted content (not an HTML document) is to use the Html component.
Html html = new Html("<div><h3>Title</h3><p><b>Bold summary text</b></p><p>Other text</p></div>");
layout.add(html);
Note, when you use the Html component, you need to strip the <head> and <body> tags, as Html's purpose is not to show full HTML documents. The Html component's content should be included inside a single root element - usually a <div> is used for this purpose.
However, based on your use case, I think the Html component will serve you well.
I'm making a web application in spring boot. I have a lot of views created in JSP, but every view has the same footer and the same menu. Of course I can just copy all menu and footer code and paste it to 30 JSP but I would like to do somethink like this: I have file in which I have something like that menu="HTML CODE WITH MENU", and then in JSP in body section I just put {menu}, and all HTML code is put inside JSP. When I want to change my menu I will just change its code in "menu" variable/string or whatever it will be, and menu in all JSP will change. I tried a few solutions for example with include but it doesn't work. I search scritly the solution I have mentioned. Has anybody got any ideas how I can do this ?
Since you are using JSP you can use the standard JSTL <c:import> tag as explained here. The other options would be to use <%# include #> or <jsp:include>, either of them will work for local files:
<jsp:include page="footer.jsp" />
<%# include file="footer.jsp" %>
<c:import url="footer.jsp" />
I have been writing c#, html, js, jquery for awhile and been using F12 in chrome and IE to look at the html code to help me with some dom manipulation. I am curious if there is a way to do something similar to that context to look at a jsp page and manipulate it with javascript.
For example: viewsource on a jsp page and fill out a textbox on the jsp page with javascript.
I hope the question is clear and the example makes sense. I am not working on anything with this so I don't have a real example. This is more of curiosity. I know javascript but I am not familiar with java at all.
The jsp file gets compiled to a servlet on the Application Server which is then executed. This servlet then produces html on the server side, therefore you can not view the jsp source code client side (F12 in chrome). You can only view the generated output (html, css, js, ...).
Source: http://oreilly.com/catalog/jserverpages2/chapter/ch03.html
JSP is compiled and run on the server side--the same place you edit it (more or less).
Only HTML is sent to the client.
In addition,
You write in C#, so if you generate simple ASP.NET page and see how a dynamic page is being generated.
It's not JSP/Java but It have the same concept of dynamic pages.
So in eclipse when you generate a .jsp file it automatically includes the following top line:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
Is there a way to also include javascript code so that I can have some of the file written in java and some written in javascript?
Usually I include my JavaScript in JSP like this:
<script type="text/javascript" src="js/script.js"></script>
This way I can minimize the js code and also cache it differently than JSP files in Tomcat.
The answer is Yes, you can add the js in jsp. And this also has benefit. It helps you to use the values stored in request and session, because the js code which contains the jsp stuff in jsp will be compiled while the *.js file will not. And also you should keep in mind that you'd better put the js code in .js file not in jsp, so the browser doesn't need to load it repeatly and code seems more clear, also good for debug. Another answer has give you the example code to import js file, so I just ignore it.
I am trying to integrate CKEditor in Netbeans to my simple web application. I did follow the documentation given in their official site, but cudnt install. It just shows a textarea instead of the editor.
Is there any tutorial on how to integrate or can anyone help me on this?
Thanks,
Shilpa
it seems you are missing to load css & js files. please check again & tell me if css & js files is downloaded & working.
You just have get ckeditor folder from http://ckeditor.com and put it outside the WEB-INF folder.And keep the ckeditor jar file in WEB-INF/lib folder.If you use jsp page get the include this tag in your page
<%# taglib prefix="ckeditor" uri="http://ekeditor.com"%> and in the body section of the html page create one textarea and replace it with <ckeditor:replace parameters />.
If you want to write all the toolbars and events in java and get them into jsp page use script lets and import these libraries. <% import page="com.ckeditor.EventHandler"%>.
If you want more examples on java refer here http://svn.ckeditor.com/CKEditor.Java. Hope this helps.