Home button for all level of url in java application - java

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>

Related

Time Out Issue in iFrame

I have one Java based web application. This application has login page where I can login into the application and go to other jsp pages. It has session time out set already in the web.xml file (let's say for 10min).
In one of the jsp page, I am showing BI report in iFrame. Now what is happening is, when I am working in BI report under iFrame for more than 10 minutes , I am getting time out message after 10 minutes., because page is not considering iFrame action as it's action, so getting time out message.
Please let me know if you have any idea or solution to ignore time out while working inside iFrame.
well you could add a javascript listener on the i-frame in order to handle the user's action when he is only active inside the i-frame
check this answer or this

how to refresh web page using java code?

I am creating a web page for an application and I need to refresh the page to see the changes.
how can I do it using Java or even ant script will do??
Thanks in advance
If you use Servlet, in your service method use code like this.
response.setHeader("Refresh", "10; URL=http://localhost:9090/J2EE_Exercise/index.html");
It will refresh my page in 10 seconds, and redirect it in "index.html" page which is the index page of my project named "J2EE_Exercise".

I want to load a browser component and want to fire a URL

I want to load a browser component using swing.
below is my full requirement
I want to create a one desktop application that will load browser component and fire one URL so that user will get one jsp page that is deployed in another server.
I googled and found one code from below link but problem is jsp page is loaded without any CSS or like that we have applied while making jsp page
http://www.java-tips.org/java-se-tips/javax.swing/how-to-create-a-simple-browser-in-swing-3.html
I verified css is applied properly by firing URL in another browser.
I tried using jxbrowser api also but that is giving me licensing error.may be it is paid version(I am not sure)
Any help would be appriciated.
Thanks in advance
you cal load browser eclipse.swt.browser.Browser class
check this url : http://www.java2s.com/Tutorial/Java/0280__SWT/UsingBrowsertoloadawebsite.htm

How to include one page from another page in 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

Redirect parent page from a ifram in JSP by JAVA

A same question can be found here . and some equal questions found.
They are about javascript (answer :-window.top.location.href = "http://www.site.com"; )
But
I want to know how to redirect it by Java in a jsp page. A usual redirect can be done as..
response.sendRedirect("newUrl.jsp");
But it redirects the source page inside the iframe not the parent page. The task is that the source file of the iframe get refreshed and do some stuff(checking session.. getting attributes. )and if the source page meets a particular logical stage,then the parent page might be redirected to another page.But not in javascript, I want to know it in JAVA( That means the jsp/servlet container decides and redirects to another page in the server).
My current opinion is that, such things might be handle with javascript.Your all info is highly appreciated.
Instead of sending a 301 or 302 redirect, send a JSP page (or write to the output stream of the response) with html content that has the javascript redirect in it set to execute on load. That way you can do your checking in the java side of things and just send the javascript redirect when appropriate, otherwise send regular content.
I have scenario like:
We have an application deployed on WebLogic and one application deployed on tomcat.
we have embeded tomcat application to run in WebLogic application.
somewhere we want to redirect the page on WebLogic application URL which is the parent application. for that if you use:
response.sendRedirect("newUrl.jsp") it will redirect to inner application URL(tomcat).
to resolve it I have used JavaScript for redirection
<%
boolean isRedirect = true // check if redirection required, I have made it true for testing
String redirectHomepage = "home.jsp";
if(isRedirect){
%>
<script type="text/javascript">
window.parent.location.href = "<%=redirectHomepage%>"
</script>
<%
return;
}
%>

Categories

Resources