Servlet to call html page
how would you publish html pages on the web. so far the html page that comes up is accessed from my hard drive ie it has H: in the URL address. can i avoid this happening?
any help is very much appreciated.
there is one other problem though. on the first html page there are 3 radio buttons and a submit button. depending on which radio button is selected, once the form is submitted it will take you to a particular html page.
once submitted it goes to the servlet with the value and name of the chosen radiobutton.
on the servlet side i have coded 'if' statements to identifiy which radio button has been chosen. from this it is to go to a sepcific page. however, from here i do i call the html page. the part of the code is below:
if(value.equals("Lectures"))
out.println("LECTURES");
out.println("<HTML>");
out.println("<HEAD><TITLE>Student's Information System</TITLE>");
out.println("<script language=JavaScript><!--function methodRetrieve(){ document.myform.submit();}</script>");
out.println("<script language=JavaScript><!--function methodEnterEdit(){ document.myform.submit();}</script>");
out.println("</HEAD>");
out.println("<BODY><FORM name=LECmyform METHOD=GET ACTION=http://brunhilde.dcs.qmul.ac.uk/~rkj1/tomcat/servlet/Lecture target=_top>");
out.println("<H1><p ALIGN=CENTER>Lecture Attendance Records</H1>");
out.println("Select one of the following:<BR><BR>");
out.println("<SELECT name=subjectMenu>");
out.println("<OPTION value=CS3>Computer Systems 3");
out.println("<OPTION value=GUI>Graphical User Interface");
out.println("<OPTION value=DLD>Digital Logic Design");
out.println("<OPTION value=DRA>Decision Risk Analysis");
out.println("</SELECT><BR><BR>");
out.println("<INPUT TYPE=button name=theButton VALUE=Retrieve Attendance Records >><BR><BR>");
out.println("<INPUT TYPE=button name=theButton VALUE=Enter/Edit Attendance Figures >><BR><BR>");
out.println("</FORM></BODY></HTML>");
this is just a rough html page but the actual page contains a lot more html and would be too silly to go about out.println it all in the servlet. is there a method that i can call from this if statement to call a html page?
please help me if you can since i've been trying this for a while...
thanks
gina
Similar Messages
-
Calling a servlet in a HTML page
hi evryone,
I'm new to servlets so i'm trying to create some simple applications to understand how it all works. The thing i'm trying to do is calling a servlet in a HTML page. I've already installed a Tomcat web server and I've created a servlet called Hello.
public class Hello extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String name = req.getParameter("name");
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>" );
out.println("<BODY>");
out.println("Hello, " + name);
out.println("</BODY></HTML>");
public String getServletInfo(){
return "testing servlet OK";
}In my HTML page I've written the follwing code:
<HTML>
<HEAD>
<TITLE>Just say hello</TITLE>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="../servlet/Hello">
What's your name?
<INPUT TYPE=TEXT NAME="name"><P>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>After running this HTML I get a text box and I thing I'm trying to do is, when I click on the button, the servlet will be loaded. However, the servlet can't be found and instead I get an error:
type Status report
message /servlet/Hello
description The requested resource (/servlet/Hello) is not available.
I suppose both file are in their approriate directories, but my class file still has the class extension. Do I need to change this? I hope that someone can help me.
Thanks in advance!hi,
the servlet wasn't in a package, so I changed that. It seems that I get an other error now:
HTTP Status 503 - Servlet servlet/Hello is currently unavailable
type Status report
message Servlet servlet/Hello is currently unavailable
description The requested service (Servlet servlet/Hello is currently unavailable) is not currently available.
I still don't know what I may have forgotten, so i'm gonna resume what i have done till now.
the servlet: (Hello.class)
package servlet;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Hello extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String name = req.getParameter("name");
out.println("<HTML>");
out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>" );
out.println("<BODY>");
out.println("Hello, " + name);
out.println("</BODY></HTML>");
public String getServletInfo(){
return "test servlet OK.";
}the HTML page (testServlet.html)
<HTML>
<HEAD>
<TITLE>Just say hello</TITLE>
</HEAD>
<BODY>
<FORM METHOD=GET ACTION="../servlet/Hello">
What's yoir name?
<INPUT TYPE=TEXT NAME="name"><P>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>the web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>servlet/Hello</servlet-name>
<servlet-class>servlet/Hello</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet/Hello</servlet-name>
<url-pattern>/servlet/Hello</url-pattern>
</servlet-mapping>
</web-app>paths of these files:
- Hello.class => D:\Tomcat 4.1\webapps\ROOT\servlet
- testServlet.html => D:\Tomcat 4.1\webapps\ROOT\more
( - web.xml => D:\Tomcat 4.1\webapps\ROOT\WEB-INF)
Thanks for your help!!! -
How to call html page with in the flash
I am new to action script, can some one guide me how to call html page with in the flash. lets say i have movie clip having instance name as "news_feed", I need to disply the html page in this news_feed. kindly help me, thanks alot
some one tell me, weather it is possible or not ??
-
Syntax for calling html page in PL/SQL package
Hi,
I'm trying to call html page (stored on server) in my pl/sql package!
I have already create html page in pl/sql package code and it's works fine.
Now create better html page (interface design) and stored on server. I would like to call that stored html page in my pl/sql package.
What is syntax for calling html page in PL/SQL or could you suggest me some literature.
In first option I had created ces and stored it on server. Then I call it in pl/sql package like htp.p('<link rel="stylesheet" href="\download\table_style.css" type="text/css">');
I try someting like that for calling html page but it doesn't works.
htp.p('<link rel="form" href="\download\interface.htm" type="text/html">');
Does anyone know syntax for calling html page in pl/sql?!?
Thanks!hello
I normally use htp.anchor(URL,linkname);
it works
ammar sajdi
www.e-ammar.com/Oracle.htm -
How To Call HTML Page Through Java Swing Page ???....
Hi All ;
Please Can You Tell Me How To Call HTML Page Through Java Swing Page ....
Regards ;Hi,
you can use HTML fragments on a panel.
http://java.sun.com/docs/books/tutorial/uiswing/components/html.html
However, to integrate a browser you need 3rd party software like IceBrowser
If you Google for: HTML Swing
then you find many more hints
Frank -
How to call HTML page through JSP ?
i want to know Hw to call Automaticly a HTML page through JSP.
example :-
have u seen yahoo login wen u put your ID & pass & Clock on login button it will chack ID & pass in the database & if it is correct then It will call A Mail Home Page.
that's same i want to do.
i have a jsp page which chacks the userID & Pass & call the first.html page
but i dont know how to call html page automaticly.
Any one can help me
what i think is this
tell me is it right or not
suppose i have made a variable
String add = "first.html"
after chacking userID & pass
if(idpass == true)
add;
if(idpass == false)
erre;
it will work or not pl tell meIf you do the redirect with javascript, the user cannot resubmit his login when he presses the refresh button. When he does press refresh, he only refreshes the redirect, not the form post that was before it. When he presses back the redirect will also kick him back in stead of going back to the login page. A simple javascript redirect page would look like this:
<html>
<body onload="document.location.href='myhtmlpage.htm';">
</body>
</html>But that is only if you care about resubmits of course. -
Servlets: Scrolling a html page
I have a servlet that generates a page with edit buttons,
rows, columns etc. When the edit button is pressed it
allows the current row to be edited (hence the name edit button ;). The problem is, when I press a button way down on the bottom of the page (scrollable) it works as it should (opens a html textfield(?) on the row) but the drawback is, that the page is hiked up and you have to scroll down and find the edit row. So is there a way I can scroll it down automatically near the edit row?
Thank youHave I understod correctly?
When you press the button the servlet generates a new page with the textfield.
You call the servlet something like this in the button: www.site.com/servlet/theServlet.
Then call it as www.site.com/servlet/theServlet#here and insert <a name="here"> before the textfield in the generated page (in the servlet code). -
Possible to make servlet look like html page?
Is it possible to register a servlet so that it looks like an html page?
for example the servlet "HelloWorld", I want to make it look
like "HelloWorld.html".What you need to do is configure your web server / servlet engine to pass EVERY request for a .html file to a servlet. This is typically done by passing the requests to a router servlet, which then reads the request URI, and then instantiates a servlet based on the desired file name. Therefore, if your requests goes to "HelloWorld.htm", the router would instantiate the class "HelloWorld", probably by calling Class.forName("HelloWorld"), and then call its doService(), doPost(), or doGet() methods.
-
How to call html page from an applet
I want to call a html page after the user presses a OK button in the applet. please help me in this.
In you actionPerformed put:
AppletContext appContext=getAppletContext();
URL myURL= new URL("http://www.javasoft.com");
String target="_self";
appContext.showDocument(myURL,target);P.S. If you want to pen the URL in a new Browser window
use
target="_blank"; -
How to call html page rear adf button
Hello,
I've an html page with javascript code and css in adf project. Is it possible to call my html page rear an adf button if yes how?af:goLink or af:goButton should do it.
-
Problems calling Java Servlets from HTML pages Online
Hello
I have created a Web site using Java Servlets, and have acquired some servlet enabled web-space however i am having some difficulty in calling the actual servlets from the HTML pages i was using the line of code as follows
http://localhost:8080/servlet/....
followed by the name eg.
http://localhost:8080/servlet/Login
however this doesn't seem to be working i have also tried using the exact address of the servlet but this didn't work either
i.e ..servlet/Login.java
I was wondering would anyone have any idea as in how the servlets should be called
Thanks very muchOnce you write the Servlet code, you have to compile and put the classes in the server classpath. To refer these servlets from your pages, you have to configure them in the server configuration(typical a xml file). There you define how you are going to refer to the servlet(/servlet/Logon) and the correponding class.
-Mak -
How to call a html page from servlet
i want to link a servlet to a html page, if i use requestdispatcher, it says XXX.html is not available, can anybody help
Can you be more specific about what you're trying to do? Can't read your mind =). But if you mean you want to just have an static HTML page such as a header read by the servlet you can you the requestdispatcher include().
Create a servlet to generate a page, and then map it as /getPage in the web.xml file. Then you can use:
// header
RequestDispatcher rd = ...getRequestDispatcher("/getPage");
rs.include(req, res);
// the rest of the servlet output
// and you can do another one for the footer down here
rd = ...getRequestDispatcher("/getPageFooter");
rs.include(req, res);
and it'll output the HTML in the servlet.
Hope this helps -
How can I generate a html page in a servlet-applet connection?
Hello, I have an applet which contains an ok button, when I click this button, I need that servlet generate an html page and view it in browser. How can I do this?
ThanksBut with this method only is possible I think open a page web, and if it is possible call url of the servlet, you generate other request and response object (other call to method doGet or doPost because ShowDocument needs parameter url), so the previously request when I click button ok it's no the same and how I obtain the prinwriter from first request, showDocument don't obtain html page from printwriter.
-
Can I display html pages in flash player
Hi all,
Can I display html pages in flash player, i mean swf. Plz
help me if it can be done. Can I call html pages in flash (i mean
in flash player no new window)
Thankshi,
Actullay i want the site to be opened with in the flash
player, just like iframe in dreamweaver calling the external site
in the mail html page. Plz Help me accessing external site page
with in flash player
Thanks -
How can I display the HTML page from servlet which is called by an applet
How can I display the HTML page from servlet which is called by an
applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
I am calling my struts action class from the applet. I want to show the response in the same browser.
Code samples will be appreciated.hi
I got one way for this .
call a javascript in showDocument() to submit the form
Maybe you are looking for
-
How to read content of Microsoft Word to Webdynpro
I always find to read the content of a doc to OfficeUIComponent is not difficult, but I wonder if I can get the plain text from the doc. I guess they read bytes from doc files can only display in OfficeUIComponent, these bytes can not be print out to
-
Hi ALL I want to add new fields on seeded EBS page to store their values in hr_api_transaction table whoch contain information of other fields on that page which are seeded but that table has one column which stores xml file and that xml file has all
-
How do I get into my iPad if I forgot my password
Help me! I forgot my password to my iPad!
-
How do I move folders and albums in iPhoto on my MacBook Pro to my ipad?
How do I move folders and albums in iPhoto on my MacBook Pro to a new iPad Air?
-
ZFS email and disk monitoring issues
Hello , I have two isuees 1.Installing Zenworks management agents on windows 2000 Advanced server slows our systems and in application logs we get Errors related to disk performance counters. "timeout waiting for perf.dll has expired" What is a perma