Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Display HTML page from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Display HTML page from a servlet" Watch "Display HTML page from a servlet" New topic
Author

Display HTML page from a servlet

David McWilliams
Ranch Hand

Joined: Mar 14, 2009
Posts: 73
Hi all,

I have written a simple servlet that I want to invoke from a web page. Basically, I want to be able to load my initial webpge, enter an email address and click submit. I want this page to pass the email address to my servlet, I want the servlet to return a list of customers associated with that email address and post them to a webpage.

Do any of you know of any tutorials I could follow to achieve this?

Most of the tutorials I have seen dynamically create the display HTML webpage, e.g.

out.print("<html><head>");

I don't want to do this. I want to creat my own webpage in my own style and have the serlvelt populate it with customer data, not dynamically create the page.

I have tried the following from my doGet() method but it doesn't work. The dispatcher is created but the html file doesn't load.





Any help is welcome,
David
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
The request dispatcher is a good start. but the keyword here is JSP. Google for a tutorial you'll find plenty.


JDBCSupport - An easy to use, light-weight JDBC framework -
Rajkishore Pujari
Ranch Hand

Joined: Sep 03, 2005
Posts: 46
http://download.oracle.com/javaee/5/tutorial/doc/bnagx.html

Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Welcome to JavaRanch..
David McWilliams
Ranch Hand

Joined: Mar 14, 2009
Posts: 73
Shanky Sohar wrote:Welcome to JavaRanch..


Many thanks..
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

and one more thing with forward, you can forward your request to any resource like jsp,servlet,HTML




but remember Forward should be called before any request should be commited to the client.otherwise you will get illegalArgumentException..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Display HTML page from a servlet
 
Similar Threads
Displaying a buffered image in html from a servlet
Dynamic XML to HTML
Forward servlets
how to call the html form
how to create data base from free web space