I need to pass params to included jsp
<%# include file="second.jsp" %>
i need to use it several times in one jsp page, so i need to pass id.
I can't use jsp:include because jsp can't see struts action in this way
Can u help me? Thank you
Set them as attributes on the request object (which makes them visible to the ${var} syntax) before invoking your include.
See How to access a request attribute set by a servlet in JSP? for a similar question.
As you know,if we want to include other pages in jsp(most are header 、footer), we can write that in our jsp file:
<jsp:include page="/pages/common/header.jsp"></jsp:include>
if I want to achieve the same function that adding some html file in thymeleaf template , how can I do? Is it OK ?
No, you can’t include jsp files in thymeleaf. But you can include other thymeleaf pages. See how :
Difference between th:insert and th:replace (and th:include)
I have a jsp code, where I fetch some JSON data from JAVA Class file. [Basically openfire users]
Now I get the data successfully, but I want to show this data in HTML table format.
How do I Do this ?
My JSP Code :
<%# page language="java" import="prov.*, java.util.*, java.io.*,java.text.*" contentType="text/html"%>
<%# page errorPage="error.jsp" %>
<%
Openfire tc = new Openfire();
tc.getUsers("192.168.50.218","epvFjHq5RHA614C7");
out.println("Data Is As Below : " + tc.getUsers("192.168.50.218","epvFjHq5RHA614C7"));
%>
And I get Response from the JAVA Class method like this :
[{"username":"abcd","name":"","properties":null},{"username":"admin","email":"admin#example.com","name":"Administrator","properties":null},{"username":"bizdd456d454mnc","email":"bizMNC#bizrtc.com","name":"bidzMNC","properties":null},{"username":"bizddd454mnc","email":"bizMNC#bizrtc.com","name":"bidzMNC","properties":null},{"username":"bizmnc","email":"admin#example.com","name":"511515151515151","properties":{"property":[{"#key":"console.order","#value":"session-summary=1"},{"#key":"console.rows_per_page","#value":"user-summary=8"}]}},{"username":"dhaval","email":"dhaval#bizrtc.com","name":"dhaval","properties":null},{"username":"keyur","email":"keyur#bizrtc.com","name":"keyur","properties":null},{"username":"minz","email":"bizMNC#bizrtc.com","name":"bidzMNC","properties":null},{"username":"patel","email":"rau#example.com","name":"patelbhai","properties":{"property":[{"#key":"console.order","#value":"session-summary=1"},{"#key":"console.rows_per_page","#value":"user-summary=8"}]}},{"username":"rajan","email":"rajan#bizrtc.com","name":"rajan","properties":null},{"username":"+username+","email":"+email+","name":"+name+","properties":null}]
As I am very new to JAVA and JSP I don't know how to parse this data to HTML Table.
So Please help.
You can see here how to do it. You can populate it in Javasript or jQuery, but it is better to use JSTL and not just call java code inside JSPs.
I would suggest you use mustache als template engine.
It allows you to use a HTML fragment as template (store it as resource) where double curly brackets (hence the name Mustache) denote the insertion points.
The full documentation of the Mustache syntax is here and a Java example here. Let us know how it is going.
I have a page whereby I am including a freemarker FTL in this way:
<#include "header.ftl">
Now, the page that it is in does not reload as it's a one pager. However, I would like that at a certain point I refresh header.ftl without doing a full page refresh. Is this possible by any chance? I am new to FTL.
You'll need two serverside endpoints, one for the whole page and another for the fragment(s).
You can then use an ajax request to refresh the fragment (eg jquery)
its some how difficult to explain it in simple words . But , I will try as much as possible.
Here is the thing :
I have jsp page FAQ in Spring MVC that uses a decorator called decorator.static.jsp
when ever a request comes to /myapp/static/** ,ok?
Then , after for a page after login I use a decorator like /myapp/secured/** then apply
decorator.secured.jsp
The problem is I have a menu on the bottom of the app like
FAQ | AboutUs | Home
and when i click on FAQ the app goes to
secure/home
instead
/myapp/static/faq/controller
How can I access static pages with like FAQ after I login.
Please , let me know if I have to explain more , Thank you Guys!
Put the top menu in a different html file say menu.html
Now include this html page on your JSP page as :
<%#include file="menu.html" %>