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.
Related
I need to render HTML page from a Java String. The String contains a full HTML page which may include CSS and Javascript. I know that some CSS/script reference may missing because I only has the html, so it's not a problem.
I have tried using JEditorPane, but it only works for very simple HTML. If it can't render, it will display nothing.
Is there any library I can use?
You can use the Desktop class. It will open the default browser of your platform.
Read the section from the Swing tutorial on How to Integrate With the Desktop Class for more information and working examples.
I have a page that built with JSP, struts.This page loading with dynamic content.
I want to save the page as PDF-file with all contents and the same format with a button click. If i can save the page with all contents, I can convert to PDF.
How to save a jsp page with this properties as pdf?
thanks in advance
I was researching this topic lately and I found that better aproach is to use javascript on client side to generate PDF.
There are few libs who can make it for you. choose your way:
f.e.
Generate pdf from HTML in div using Javascript
http://html2canvas.hertzen.com/
https://github.com/MrRio/jsPDF
(:
I am in the process of building a JSP based website using the Spring MVC framework and Bootstrap, and I have all of my separate web pages pretty much done. A little late in the game I've decided that I want to add a navigation bar to my website. I've created the navigation bar already but is there some easy way to "tack" it onto the other web pages easily so I don't have to duplicate code in separate files?
If I put the navigation bar HTML code in a separate file and include it on a JSP page, will it show up appropriately?
Is there a normal standard way people extend navigation bars to their whole website? I'm sure people who have experience creating websites should be able to easily answer this. I certainly appreciate any help that can be offered. Thank you!!!!
Make a tag. Like navbar.tag in tags directory which will be in your WEB-INF dir. Add your code there and include it in desired JSP pages.
To include your tags in JSP add this into a header:
<%# taglib prefix="mytags" tagdir="/WEB-INF/tags" %>
And use your tag like this:
<html>
<body>
<mytags:navbar/>
</body>
</html>
You can use any Layout template framework such as Sitemesh or Tiles with Spring MVC. You need to add your navigation into the template layout (Master layout page) so your navigation bar will be displayed on any pages that referencing to the layout.
See this post: How do I integrate Sitemesh 3 with Spring MVC 3?
Other resources:
http://codesilo.wordpress.com/2013/07/11/spring-mvc-with-sitemesh-3/
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" %>
I am using Jsoup to parse an webpage this one https://daisy.dsv.su.se/servlet/schema.MomentInfoRuta?id=261020&kind=100&nochange=true&allPrio=true&multiple=true&allEx=true
In that webpage i can see something in the browser but when i am trying to parse it with Jsoup
Document doc = Jsoup.parse("https://daisy.dsv.su.se/servlet/schema.MomentInfoRuta?id=261020&kind=100&nochange=true&allPrio=true&multiple=true&allEx=true");
System.out.println(doc);
It will return
<html>
<head></head>
<body>
https://daisy.dsv.su.se/servlet/schema.MomentInfoRuta?id=261020&kind=100&nochange=true&allPrio=trueμltiple=true&allEx=true
</body>
</html>
Which is not all HTML.
Any suggestions how i can solve it or why it is happening?
That looks like they're detecting a crawler, usually via your user agent, and sending different content. Try setting your user agent string to a standard browser's string, and see if that resolves the issue you're having.
One other potential problem, though I don't think it's the issue here, is data loaded in via AJAX will not be downloaded by JSoup. It parses the HTML that gets served up, but it doesn't execute the JavaScript, so it can't get any extra content that comes in later. You might be able to resolve that issue using something like PhantomJS which can process and render HTML, CSS, and JavaScript, and would (in theory) give you the actual HTML you end up seeing in your browser.