This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes Calling Html file from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calling Html file from a servlet" Watch "Calling Html file from a servlet" New topic
Author

Calling Html file from a servlet

Swaminathan Balasubramani
Ranch Hand

Joined: Apr 12, 2005
Posts: 38
hi,
In my application i have many html files, The welcome html file displays the username and password. On entering the
Username and password the user is given access to the second html file where the user can use the application eg searching
file...I have dont the welcome html page and i've written the Servlet and deployed it in the J2EE 1.3.1, Suns Application server.

I'm printing a messge "Invaild username and password" in case if the username and password do not match aganist the one in the database.
On the otherhands i should display another HTMl file if the username and password is valid..

can anyone tell how to call the second html file, ie on clicking the submit button the next page should be displayed..

can anyone tell me how to do this..


B.Swaminathan<br /> <br />Mobile:+91 09886510453
Kutub Shaikh
Greenhorn

Joined: Apr 04, 2005
Posts: 13
Hello Swami..

you need to use RequestDispatcher for this pupose..

e.g.
RequestDispatcher rd=request.getRequestDispatcher("/applicationname/xyz.html");
rd.forward(request,response);


Take Care..


The Man With The Golden Gun...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Swaminathan Balasubramani:

can anyone tell how to call the second html file, ie on clicking the submit button the next page should be displayed..
can anyone tell me how to do this..


Swaminathan,
If you're not sure how HTML forms submit, I would take a little time away from this project to follow some tutorials, both on Servlets and on HTML.
There is an excellent chapter on HTML Forms (chapter 16) in Core Servlets and Java Server Pages. This book can be downloaded for free at http://pdf.coreservlets.com
The time you spend getting this under your belt will more than pay off in the long run. Both in time and frustration saved.

Good-Luck
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Swaminathan Balasubramani
Ranch Hand

Joined: Apr 12, 2005
Posts: 38
Thanks Ben,

Thank u so much..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling Html file from a servlet