Vijay Kumar
Servlet Generates HTML
2 Answer(s)      2 years and 7 months ago
Posted in : Servlet Interview Questions

How Servlet Generates HTML ?

View Answers

November 3, 2010 at 4:34 PM


Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request. In servlet chaining, one servlet?s output is the input of next servlet. This process continues until the last servlet is reached. Its output is then sent back to the client. We are achieving Servlet Chaining with the help of RequestDispatcher.


November 3, 2010 at 6:02 PM


HTML is with a type of text/html, so the code would look like this:

response.setContentType("text/html");

Example :

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      String docType ="<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 " +
     "Transitional//EN\">\n";
     out.println(docType +
     "<HTML>\n" +
     "<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
     "<BODY BGCOLOR=\"#FDF5E6\">\n" +
     "<H1>Hello</H1>\n" +
     "</BODY></HTML>");
}
}









Related Pages:
Servlet Generates HTML
Servlet Generates HTML  How Servlet Generates HTML ?   Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request. In servlet chaining, one servlet?s output is the input
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
html and servlet file
html and servlet file  where to place the html and the servlet class... html file with the jsp files amd servlet file insdie classes folder of tomcat. You have to specify the full path of servlet on html action if you want to call
Html Template - JSP-Servlet
Html Template   I use a template to design my website,but some problems arised using template.I pass flag update and insert as a hidden field on to the servlet,the response of the servlet is a jsp page.on this page template
html form - JSP-Servlet
html form  how to retrieve database value in dropdown list box placed in html form  Hi friend, Visit for more information. http://www.roseindia.net/jsp/ Thanks
send HTML Email with jsp and servlet
send HTML Email with jsp and servlet  Can You please show me how to send html Email using JSP and Servlet thank you
Servlet Tutorial
and process the HTML form data. Servlet is used to provide dynamic content...Servlet Tutorial In this section we will discuss about Java Servlet. This section describes you What is Servlet, Use of Servlet, Servlet container, Servlet
html-jsp
html-jsp  If i want to get dynamic value in html textbox or in jsp,then how can I get the value,how the value will be transfered from servlet page to the html textbox.Thanx in advance.....Kindly help me
html dropdownlist code - JSP-Servlet
html dropdownlist code  hi how to get textfield in html when i select the option others in the dropdown list, pls provide the code?   Hi Friend, Try the following code: function show(){ var op
how to update values of a html form into an excel table using java servlets?
how to update values of a html form into an excel table using java servlets?  i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
html-jsp - getparameter() - JSP-Servlet
html-jsp - getparameter()  Hi! friedns, This is my front end and I want to retrieve username and password in two different jsp pages. I used getParameter() with two form action as shown below. But I am not getting
Html/JavaScript code - JSP-Servlet
Html/JavaScript code  I have 2 JSPs JSP1 and JSP2. 1.in JSP1 i have a table being displayed using the tag and cells in it contain links(huge amount of data is displayed in paged manner). 2.When click on a link, it leads
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet
servlet  dear sir servlet and html not run on eclips plz help me
Calling hibernate query list() method generates errors
Calling hibernate query list() method generates errors  Hello, I'm trying to debug someone's codes. But I am not an expert of hibernate so I'm asking your help about this. I am trying to retrieve a list of jobs from
Uploading file in servlet from a html form
Uploading file in servlet from a html form  Sir, I want to upload a picture from my html file and save it to my database as BLOB,but what JAR should i use for this purpose i am really confused about.And also is it possible to do
how to execute the below servlet with html page
how to execute the below servlet with html page  //vallidate user n...,ServletException { res.setContentType("text/html"); PrintWriter out=res.getWriter... res)throws IOException,ServletException { res.setContentType("text/html
create html of word ,excel,ppt - JSP-Servlet
create html of word ,excel,ppt  Plzz tell me how to create html page of word , excel ,ppt document dynamically using jsp because in my project I have to store uploaded files as html page
Servlet
Servlet  I want to know the steps to write a simple servlet program... .   Hello Friend, Follow these steps: Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet. import java.io.*; import
servlet
servlet file which prints out the user's inputs. I need to use the post method to pass the data from html to the java servlet and also use both doGet... create a html file that contains four text boxes, first and last name, address
servlet
create a html file that contains four text boxes, 'Watch me', 'Color' and 'size... in watch me as we set the following options. I need to connect the html code to servlet. So, if anyone can help me so I can see how to connect the two I would
Data fetching from JSP or HTML - JSP-Servlet
Data fetching from JSP or HTML  Hi Deepak, Can u pls help me as i have a problem with jsp/html frameset. my question is how can i fetch the data from frameset which is in html format.pls help me. Thanks
to run html code in web browser - JSP-Servlet
to run html code in web browser  how to run jsp file which calls html file on web browser??  Hi Friend, Try the following code: 1)form.jsp: Enter Name: 2)welcome.html: Add Profile Edit
JSP:HTML Form in-place Editing - JSP-Servlet
JSP:HTML Form in-place Editing  I have an HTML form (form #1) which uses a java servlet to save customer data by entering values into textfield... of a customer search in a small table on the same page using another servlet(also working
HTML code to servlet to database using jdbc
HTML code to servlet to database using jdbc  pls send me the code related to the title   Hi Friend, Try the following code: 1)form.html...=req.getParameter("msg"); res.setContentType("text/html"); PrintWriter
SERVLET
to the servlet and if the user id is correct then a new page will be displayed with his... pass to the servlet and all the fields brlongs to that id will be appear... will be done by using jsp and servlet... Plz help me,im really tensed...........  
Servlet: What is it
, programmer can store data that was submitted from an HTML form. Servlet is also used.... Servlets are quick as they are pure java classes. Servlet embeds HTML inside Java code. A Servlet generates a response according to the request it receives
Servlet
the same error <web-app> <servlet> <servlet-name>InsertServlet</servlet-name> <servlet-class>InsertServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>
servlet
servlet  how to jsp integer are type cast int servlet page   Hi Friend, Try the following code: 1)form.jsp: <form method="post...) throws ServletException,IOException { response.setContentType("text/html
HTML - Q (quotation) tag.
HTML - Q (quotation) tag. Description : It generates a quotation over the text. Code : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0....dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
JSP:HTML Form in-place Editing - JSP-Servlet
JSP:HTML Form in-place Editing  Hi, I want to thank the people who took the time and made the effort to respond to my 2 questions posted, truly... developer's needs. This is a follow up to the HTML Form in-place editing. The code
JSP,JDBC and HTML(Very Urgent) - JSP-Servlet
JSP,JDBC and HTML(Very Urgent)  Respected Sir/Madam, Thanks... details from database using JDBC and JSP. The home page i.e HTML Page must contain... the code: I am not using any html. I used only jsp & jdbc. HOme Page
servlet
=res.getWriter(); res.setContentType("text/html"); pw.println("Hello"); try...); } } } this is the code for .java servlet am able to run sucessful but when i give wrong
i use HTML in jsp - JSP-Servlet
i use HTML in jsp  i want to make a list box of select state and corresponding to the selected state all the names of cities will be displayed in another list box.   Hi display list Selects
servlet
{ response.setContentType("text/html"); PrintWriter pw = response.getWriter(); counter
servlet
com.ilp.tsi.um.bean.BankBean; import com.ilp.tsi.um.service.BankService; /** * Servlet...("text/html"); PrintWriter pw = response.getWriter
servlet
ServletException, IOException { response.setContentType("text/html"); PrintWriter pw
JSP - JSP-Servlet
JSP   Hi! this is my html page which generates data dynamically in div content.... I want to store the content of div content in database Please help me..... Thanks in advance... Hello World
SERVLET
("text/html"); PrintWriter out=response.getWriter
SERVLET
("text/html"); PrintWriter out=response.getWriter
jsp or sevlet and html form to send picture to database - JSP-Servlet
that contains his picture to database. What I need are html page for the form that will browse for the picture, jsp or servlet that the info from html will go...jsp or sevlet and html form to send picture to database  Hello guys
how to call servlet from html page at anchor tag ?
how to call servlet from html page at anchor tag ?  I have a very different problem as i am using netbeans ide 6.9 ml to make a website in java... to other page and at that place i give url of a servlet but in server that url
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML