Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

begin learning servlet,find it very hard to input code?  RSS feed

 
Jeffrey Ye
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so many kinds of code:,<>,"",/\,%,+,#

somebody give me suggestions

i take about 8 minutes to input the following code:

out.println("<!DOCTYPE HTML PUBLIC\"-//W3C//DTD HTML 3.2//EN\">");
+"<HTML>"
+"<HEAD>"
+"<TITLE>"+"FIRST SETVLET"+"</TITLE>"
+"</HEAD>"
+"<BODY BGCOLOR=\"#FFFFFF\">"
+"<CENTER>"
+"<H1"+"HELLO WORLD"+"</H1>"
+"</CENTER>"
+"</BODY>"
+"</HTML>");



 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't do this in your servlet.
Use a simple html file, or jsp whatever technology you want to display something.

Redirect from the servlet to the view. It's a one liner.
Takes 8 seconds

Search more about RequestDispatcher.
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Satou is absolutely right. Your scheme of writing in servlet is right, but only for the HelloWorldServlet.
You should redirect from your servlet to an HTML or JSP file.
Here is how to do this:


And it takes lesser than 8 seconds if you are not doing high computation.

Enjoy,
Abhishek
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They care about you, therefore JSP is there to get rid of complex servlet codes. JSP is used for presentation stuff, as mentioned earlier.

Cheers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!