How can I export jsp to doc file? - java

I have to add a Button to a JSP to export the page in Word format (.doc or .docx).
I found How can we export jsp to doc file? but the link stackoverflow.com/questions/5946032/export-jsp-to-doc-fomat doesn't work anymore.
Do you have a simple example to solve my task or a working link?
Thanks in advance!

I found the indication of adding these two lines at the top of JSP, which seems to work:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%# page language="java" contentType="application/msword; charset=windows-1252" %>
Thank you to help me to refine the searching !!

Related

Spring Boot cant serve css file with Thymeleaf View

I am making an app with Spring Boot.
I have a Thymeleaf view chat.html in resources/templates/chat.html I include style.css stylesheet in it.
When I load the chat.html in browser only html shows without any stylesheet.
Here is chat.html
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link href="styles/style.css" rel="stylesheet">
<title>Chat Web App</title>
</head>
...some irrelevant html ...
<body>
</body>
</html>
I have put the style.css in resources/static/styles/style.css as per several other answers for same problem but no bueno. Perhaps some additional configuration need to be made or i am simply making a dumb typo.
The issue was actually in my CSS file :) . Apparently i had selectors for classes that werent present in the html. After removing them the solution proposed in the comments worked fine!

Substitute for siteedit taglib on JSP

I'm working on a project that has some JSP in it, with has some taglibs that don't work anymore, and I've searched far and wide, and can't find a replacement for it. Has anyone run into this problem? This was only used for some navbars.
The taglib in question is the following:
<%# taglib uri="http://www.ibm.com/siteedit/sitelib" prefix="siteedit" %>

integrating html design to servlet

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" %>

where and how to link html file,css file,javascript file and jsp

i have CSS file in one folder,html file in one folder,javascript in one folder. where shoul i link these files and how?whether in html or jsp page.please let me know.. even after giving a link like
where CSS is my folder.
how a proper aggregation is needed in in eclipse considering the industry standards ?
You link the files on your html page in the head of the document.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../css/main.css">
<script src="../js/main.js"></script>
</head>
...
Some people recommend linking javascript at the end of the document (just before the closing body tag) so that the visible elements can be rendered first before the javascript is parsed.
Just to clarify, css must be in the head; javascript can be anywhere and possibly/probably optimal at the end.
use link element to link various resources to your page like: CSS files, a favorite icon ...
check out this video demo
and script tag (as shown above by Crazysheep) to link scripts

using javascript in .jsp file

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.

Categories