How to include one page from another page in java? - java

I am new in java and i am developing web application in java.
I am trying to include one page to another page.But it gives path error in server side.
My another page is placed in user folder of root directory.
I am trying to include page like
<%#include file="../user_menu.jsp" %>
Its working on local host but not working in live linux server.
How can i fix this error?
Help me

Use /path/to/your/file.jsp
Where / is your public_HTML dir

Related

Home button for all level of url in java application

I have made my application to run as root in tomcat using This post.
Now my application coming in browser as http://localhost:8080/ instead of http://localhost:8080/myApp/ As i Expected.
I have single menubar at the top which is same for every page using <%#include file="/jsp/header.jsp" %>
There is home button what will bring user to the home page from any level of url like http://localhost:8080/a http://localhost:8080/a/b/c all to http://localhost:8080/.
before making my app root i was using
<a class="...." href="${pageContext.request.contextPath}">Home</a>
But now ${pageContext.request.contextPath} value is and empty string()
. so the generate html is
Which is only reloading the current page when clicked.
What should i do to make it work like before. And i would like to make it server independent (now it is in local host some day it will go to a real serve i hope).
You should be able to add a / character and have the URL work in both cases.
<a class="...." href="${pageContext.request.contextPath}/">Home</a>

Publish a locally generated report on the server

I have my web application running using a tomcat server on localhost:8080/myWebApp
Internally I accomplish a task of creating a report which is stored locally at "C:/project/myProject".
I can view the report by opening "C:/project/myProject/report.html" manually. I want to integrate this into my web application.
I tried writing a jsp file to open this "report.html" but that does not seem to work.
myJsp.jsp
<a href='file:///C:/project/myProject/report.html'>View Report</a>
This doesnt work.
Edit: I do not want to store the report in my webapp directory because it will be deleted when I build the new .war file and deploy it.
I think you access the webpage is not from localhost.
the problem is
<a href='file:///C:/project/myProject/report.html'>View Report</a>
href is relative to the machine which access from (using the brower). so if access in localhost, you can get resource from file:///C:/project/myProject/report.html , but from some other machine , the resource file:///C:/project/myProject/report.html is not able to touch.
if you want to access the resource , you can easily publish content in web by any web server (nginx/apache/IIS/tomcat) or some file content service, and point the href there
Either put that in your current application folder and access directly
<a href='report.html'>View Report</a>
Or go to that folder path using:
<a href='../../report.html'>View Report</a>
or try using your ip:
<a href='http://<ip address>:<port>/<folder_path>/report.html'>View Report</a>

how to fetch a JSP page residing on a remote machine?

I'm looking for a way within Spring MVC to put my JSP pages in a remote machine and load them when I need them.
The reason I wanna do this is because my application received some page templates from users and I have to save them somewhere and load them dynamically when that page get requested! I was thinking if I want to put my users' JSPs pages inside my web-app on real time, It's not possible so I have two choice :
1) save it in a remote place and get reference to it while a request comes in
2) save them inside database which I think that's not good because the user page may have so many visitors ...
What solution you suggest ?
Using unix? Maybe you could mount the remote server and create a symbolic link to WEB-INF/jsp directory to point to the remote mount.

Java Jease CMS, Index page setup

I have converted my static website into Jease, through localhost:8080/cms, and I can access my website using the URL localhost:8080/index.html and from there I can browse around my entire website. What I am not sure about, how can I configure Jease to directly go to index.html page as soon as I type localhost:8080? Because once I make it globally available I want to make sure the index.html page is accessed through mywebsite.com URL.
Any hints would be appreciated.
Thanks
I am using JeaseCMS 2.8 and the default page already is index.html according to web.xml file.
But this welcome file isn't necessary.

Importing the content of another web resource using JSTL

I have a JSP page that will display the exact content of another web page on a different server. My understanding was that c:import from the JSTL should be able to include content from files that are not part of the current web application.
I added c:import url="page on my server in a different application" and it works fine, but when I try to include a page from another server it fails.
Any suggestions as to what might be wrong?
EDIT: The exact error is: "The server encountered an internal error () that prevented it from fulfilling this request.". However, requesting a page from the same server, different app works...I get the content of the page.
I had a similar error once. It turned out to be that the machine that I was running the app on had some problems connecting to the internet through the firewall. Once I deployed the app to a machine that was always connected it worked fine.
An exact code and how "it fails" would be a great help. All mind-readers are currently on vacation.
Meanwhile, take a look at http://www.ibm.com/developerworks/java/library/j-jsp06173.html
<%# taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
...
<c:import
url="http://www.truenorthguitars.com/Clients/Richman/index.htm" />
If it works from the same server, different app, makes it possible that there's a variable that's not being initialized somewhere, or some state which makes it throw an exception. Check the error logs for any stack traces that could point to the specific line of code that's causing the problem.

Categories

Resources