how to refresh web page using java code? - java

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

Related

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 can I tell the browser to load a html file with a Java servlet?

The idea is that you can add something to a database, which goes from browser -> java code -> JSP -> java code -> database, and you are then redirected to a page containing the information you sent. The servlets are in place but I cannot redirect to the HTML page from a get request.
I have a servlet to PrintWriter().print() the data in a Json object, but that servlet is called from the javascrit within the HTML page. How can I send the HTML page? Should I parse the HTML page and PrintWriter().print() each line? Is there a more proper way of doing this?
Keep in mind that sending HTML straight from JSP is not an option, and I can't change the structure of the system.
edit: Sorry, I typed that in a rush.
As a preface, the system is similar to StackOverflow, whereby you can submit a 'request' which prompts the community to crowd-source learning material.
Right now, the structure of the system is JS/HTML on the browser side, which communicates with a mySQL DB through an API written in Java. The API goes through JSP which communicates with an inner Java API for accessing the DB. The catch is that I must return Json objects from the API. I know that JSP is essentially useless and I could interface the two APIs without JSP, but this is a first year college project so I don't have the choice.
When you submit something to the database using the url /addrequest (or similar), the system puts the text into the database and then redirects you to /request/idnumber. When you access the /request/* URL, another servlet runs. I want this servlet to tell the browser to open my "request_display.html" page. Then the javascript on that page will call another url to get the Json object through the API, and then it will build the page.
I don't know how to tell the browser to open a html page. Should I just parse the html file and then use response.GetWriter().print() to do send the HTML?
If you are in a Servlet:
response.sendRedirect("pathOf YourHTMLPage");
If you are in a JSP page, try using a form or a "a" element. Like this:
<form action="nameOfYourServlet"></form>
or
Can't really understand what you are looking for but if you want to redirect user to an html page using servlet this can be done using response.sendRedirect("path to html");
It would be nice if you could explain via some code as your English is hard to understand.
response.sendRedirect("redirect.html");
Alternative way
ServletContext sc = getServletContext();
sc.getRequestDispatcher("/redirect.html").forward(request, response);

Where to define the login.flt as home page in alfresco-surf framework?

I have new bie to alfresco-surf framework and created one small application. I can access my page using http://localhost:9090/surf/page?p=login url but when i typed only http://localhost:9090/surf its showing
HTTP Status 404 - /surf/
Also I want to use this page for authentication and want to call my Java class to authenticate the user from database. but i don't know how to call my Java class and where to configure.
I create login.xml inside the WEB-INF\classes\alfresco\site-data\pages\login.xml
also create the template instance.
Please help I want to make it as my home page and want to call my custom java class for authentication and want success or failure to render home page.
I got it working.
In \webapps\surf\WEB-INF\classes\alfresco\site-data\configurations there is a file named
default.site.configuration
In this file we have to mention the root page.

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.

JavaScript Context in HttpClient

hi i need to Execute all the java Script on the page that i downloaded using HttpCleint Get method, which are the steps to perform the execution of the javascript containned on the page on the context of the page without loosing the connectio to the server. thx
Have a look at htmlunit don't know if you can pass your downloaded page but it can download the page it self.

Categories

Resources