Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Java Server Pages

April 5, 2000

As described earlier JSP build on the ASP technology and use Java as a programming language.

We saw the WelcomeServlet which takes myName as a parameter from HTML-form and displays a personalized welcome message. Now let's see how to achieve the same with a JSP:

Welcome.jsp:

		
<HTML>
 <HEAD>
 <B> Welcome  <%= request.getParameter("myName")%>
</B>
 </HEAD> 
</HTML>

That's all ! Suddenly life's become easy huh?

The code between "<%" and "%>" is executed at the server and the HTML, with the results, is passed back to the client.

One important fact about JSP one should always keep in mind is: every JSP is internally converted into a servlet. So even if it looks simple it it is probably going to put more 'load' on your m/c. A rule of thumb is 'if you have a lot of HTML code and some 'run time variables' use JSP. If you need a lot of processing, a servlet is the best choice. Actually one can 'interleave' servlets and JSP. We will see that in the next section.

There are some pre-defined objects (such as request, response and session) available to each JSP. We can use all the normal programming constructs such as:

<% if ((request.getParameter("myName") == "Harshal") {%>
       <B> Hey we have the same name !</B>
<%  } else { %>
       <B> Welcome <%= request.getParameter("myName") %> </B>
<%} %>

Finally, we can call methods of an external program - Java bean.

Additional JSP resources:

HTML Generation
Building Web Applications Using Servlets and JSP
The Session Object


Up to => Home / Authoring / Java / Servlets




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers