Importance of Servlet and Java Script Programming

Tutors

Importance of Servlet in Programming

Servlets are used as internal components inside higher level frameworks. Servlets are a low level API, and it’s generally more productive to use a higher level API and concentrate on the application.

  • Better performance: because it creates a thread for each request not process.
  • Portability: because it uses java language.
  • Robust: Servlets are managed by JVM so we don’t need to worry about memory leak, garbage collection etc.
  • Secure: because it uses java language..

Difficulties faced by a student while solving Servlet problems

  • Usage of Library files in JavaServlet
  • should have good skill in Java programming
  • Technical Issues – Connectivity problems (server & client programming)
  • Need more development time

Few important applications of Servlet

  • Web site
  • HTTP requests
  • Container
  • Server
  • Database Access

SERVLET Online Book Store

Program:

<%–

Document   : index

Created on : Jan 2, 2012, 11:10:26 AM

Author     : staff

–%>

<%@page contentType=”text/html” pageEncoding=”UTF-8″%>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

“http://www.w3.org/TR/html4/loose.dtd”>

index.jsp:

<html>

    <head>

        <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>

        <title>Online Book Store</title>

    </head>

    <body>

        <h1>Online Book Store</h1>

        <form method=post action=”cyber”>

Subject<br>

<select name=”subject” size=1>

<option value=”java”>Java

<option value=”vb”>VB

<option value=”c”>C

<option value=”c++”>C++

</select>

 

<input type=”submit” value=”Find”>

</form>

    </body>

</html>

Cyber.java:

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.lang.String;

public class cyber extends HttpServlet

{

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,java.io.IOException

{

  resp.setContentType(“text/html”);

  PrintWriter out=new PrintWriter(resp.getOutputStream());

  String subject;

  subject=req.getParameter(“subject”);

 String name=subject;

  out.println(“<html>”);

  out.println(“<head>”);

  out.println(“<title>Cyber Book Store</title>”);

  out.println(“</head>”);

  out.println(“<h2>Dear Customer these are the newbooks available in “+ name+”</h2>”);

  out.println(“<center><table border>”);

  out.println(“<tr>”);

  out.println(“<th>Author</th>”);

  out.println(“<th>Books</th>”);

  out.println(“<th>Price</th>”);

  out.println(“</tr>”);

  if(name.equals(“java”))

   {

    String author[]={“Dietel”,”Gosling”,”Jaworsik”};

    String java[]={“How to Program”,”Intro to JAva”,”Instant Java”};

    String price[]={“Rs.150″,”Rs.250″,”Rs.200”};

    for(int i=0;i<3;i++)

    {

      out.println(“<tr>”);

      out.println(“<td>”+author[i]+”</td>”);

      out.println(“<td>”+java[i]+”</td>”);

      out.println(“<td>”+price[i]+”</td>”);

      out.println(“</tr>”);

    }

   }

  if(name.equals(“vb”))

   {

    String author[]={“Denning”,”Gosling”,”Balagurusamy”};

    String vb[]={“Programming in VB”,”Intro to VB”,”Basic VB”};

    String price[]={“Rs.150″,”Rs.250″,”Rs.200”};

    for(int i=0;i<3;i++)

    {

      out.println(“<tr>”);

      out.println(“<td>”+author[i]+”</td>”);

      out.println(“<td>”+vb[i]+”</td>”);

      out.println(“<td>”+price[i]+”</td>”);

      out.println(“</tr>”);

    }

   }

  if(name.equals(“c”))

   {

    String author[]={“Dietel”,”Platt”,”Kanitkar”};

    String c[]={“How to C Program”,”Intro to C”,”C Puzzels”};

    String price[]={“Rs.150″,”Rs.250″,”Rs.200”};

    for(int i=0;i<3;i++)

    {

      out.println(“<tr>”);

      out.println(“<td>”+author[i]+”</td>”);

      out.println(“<td>”+c[i]+”</td>”);

      out.println(“<td>”+price[i]+”</td>”);

      out.println(“</tr>”);

    }

   }

  If (name.equals (“c++”))

   {

    String author [] = {“Dietel”,”Balagurusamy”,”Jaworsik”};

    String c1 [] = {“How to Program”,”Intro to C++”,”C++ Pearls”};

    String price [] = {“Rs.150″,”Rs.250″,”Rs.200”};

    For (int i=0; i<3; i++)

    {

      out.println(“<tr>”);

      out.println(“<td>”+author[i]+”</td>”);

      out.println(“<td>”+c1[i]+”</td>”);

      out.println(“<td>”+price[i]+”</td>”);

      out.println(“</tr>”);

    }

   }

      out.println(“</table></center></html>”);

      out.flush();

}

}

1.      Live Servlet writer support 24×7 of Mywordsolution.com Website

Provide deep insight of the subject using extensive examples, videos, quizzes, and assignments. Our content provides a clear view to analyze the current scenario to make use of the concepts practically. Also video tutorials by special professors are available on our website thus highlighting the world wide recognition of Mywordsolution.com Website.

With our highly intellectual online tutors, all your doubts would be taken into consideration 24*7 with immediate replies. Please do not hesitate to contact us with any query/help or comments you may have in Servlet.

 

Difficulties faced by student while solving  Java Script.  Problems

  • Usage of Library files in Javascript
  • weak-typing
  • lack of static types

Importance of Java Script.

  • Less server interaction
  • Immediate feedback to the visitors
  • Increased interactivity

Difficulties faced by a student while solving Java Script. Problems

  • Usage of Library files in Javascript
  • weak-typing
  • lack of static types

Few topics in Java Script  Problems

  • Javascript variables & operators
  • Functions
  • Cookies
  • Events
  • Errorhandling
  • Validations

1.             JavaScript is :

  • JavaScript is a lightweight, interpreted programming language.
  • Designed for creating network-centric applications.
  • Complementary to and integrated with Java.
  • Complementary to and integrated with HTML.
  • Open and cross-platform

Simple JSP Application

Program:

Index.html

<!–

To change this template, choose Tools | Templates

and open the template in the editor.

–>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>

<html>

<head>

<title></title>

<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>

<title>JSP Page</title>

</head>

<body>

<h1>Welcomne to Our Softy Ice Cream</h1>

<p>Name:</p>

<form action=”order.jsp” method=”post”>

<input type=”text” name=”name”>

<p>  <select name=”icecream” >

<option value=”Vennila”> Vennila</option>

<option value=”chocolate”>Chocolate</option>

<option value=”Strawberry”>Strawberry</option>

</select></p>

<p> Topping:<br>

<input type=”checkbox” name=”topping” value=”Nutts”> Nutts

<br>

<input type=”checkbox” name=”topping” value=”Butter”> Butter

</p>

<p>

Place:<br>

<input type=”radio” name=place value=”here”>Here<br>

<input type=”radio” name=place value=”out”>Out

</p>

<input type=”submit” value=”order”>

<input type=”reset” value=”reset”>

</form>

</body>

</html>

Order.jsp:

<%–

Document   : order

Created on : Jan 2, 2012, 11:25:19 AM

Author     : staff

–%>

<%@page contentType=”text/html” pageEncoding=”UTF-8″%>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

“http://www.w3.org/TR/html4/loose.dtd”>

<%String name=request.getParameter(“name”);%>

<%String icecream=request.getParameter(“icecream”);%>

<%String[] kind=request.getParameterValues(“topping”);%>

<%String place=request.getParameter(“place”);%>

<%int i;%>

<html>

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>

<title>JSP Page</title>

</head>

<body>

Mr./Ms. <%=name%>

Welcome to our Shop for purchasing<%=icecream%>

<%if(kind==null){%>

with no topping

<%}else{%>

with Topping

<%for(i=0;i<kind.length;i++){%>

<%=kind[i]%>

<%}%>

<%}%>

<%if(place.equals(“here”)){%>

Enjoy Eating Here

<%}else{%>

Enjoy outing out

<%}%>

</body>

</html>

Can support to develop your web based applications in simple and easy steps. 

Full Grade

Author Since: April 30, 2015

We have the best Learned Professional Academic Freelancers team dedicated to deliver the best. Homework Help, Assignment Help, Engineering Projects Helps, Online Course Work Help, Term Paper Writing, Essay Writing, Research Paper Writing, Lab Reports, Project Management Assignment, or whatever you have for us.

Leave Your Comment

WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. You can send Assignments directly to support team.
👋 Hi, how can I help?
Full Grade We would like to show you notifications for the latest news and updates.
Dismiss
Allow Notifications