Monday, 29 August 2011

SERVLET DEPLOYMENT STEPS

Set the PATH as:
C:\Program Files\Java\jdk1.5.0_05\bin
Set the CLASSPATH as :
C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar
write the java file and compile it and copy the classfile into the following folder
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\servlets-examples\WEB-INF\classes
Update the XML FILE: web.xml
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\servlets-examples\WEB-INF
<servlet>
        <servlet-name>RequestInfo</servlet-name>
        <servlet-class>RequestInfo</servlet-class>
    </servlet> 
 <servlet-mapping>
        <servlet-name>RequestInfo</servlet-name>
        <url-pattern>/servlet/RequestInfo</url-pattern>
    </servlet-mapping>

Run Tomcat welcome page
http://127.0.0.1:8080/servlets-examples\servlet\HelloWorld1

Saturday, 27 August 2011

//Login Page Validation using "getInitParameterNames()" method

//Login Page Validation using "getInitParameterNames()" method
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Validation1 extends HttpServlet
{
    public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException
    {
        response.setContentType("text/html");
        PrintWriter pw=response.getWriter();
        Enumeration params=getServletConfig().getInitparameterNames();
        String name=request.getParameter("username");
        String pass=request.getParameter("password");
        String pass1=" ";
        while(params.hasMoreElements())
        {
            String name1=(String)params.nextElement();
            if(name1.equals(name)
            {
                pass1=(string)getServletConfig().getInitParameter(name1);
                if(pass1.equals(pass))
                {
                    pw.println("<h1>WELCOME TO BOOK SHOP" + name1 +"<h1>");
                    break;
                }
                else
                {
                    pw.println("YOU ARE INVALID USER");
                    break;
                }
            }
   
        }
        if(pass1=="")
        pw.println("YOU ARE INVALID USER");
    }
}



Login Page Validation Using Cookies - Week 8 Program using servlets

                //Login Page Validation using cookies
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Validation extends HttpServlet
{
    public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException
    {
        response.setContentType("text/html");
        PrintWriter pw=response.getWriter();
        Cookie[] cookie=request.getCookies();
        String name=request.getParameter("username");
        String pass=request.getParameter("password");
        String pas=" ";
        for(Cookie obj:cookie)
        {
            if(obj.getName().equals(name))
            {
                pas=obj.getValue();
                if(obj.getValue().equals(pass))
                {
                    pw.println("<h1>WELCOME TO BOOK SHOP" + name +"<h1>");
                    break;
                }
                else
                {
                    pw.println("YOU ARE INVALID USER");
                    break;
                }
            }
   
        }
        if(pas=="")
        pw.println("YOU ARE INVALID USER");
    }
}



WT lab Servlets Programs - Week 8

Next week who are having the lab note down the following programms in your observation then come to the lab.
//Program Number 1 for Week 8: SetCookies.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SetCookies extends HttpServlet
{
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException
    {
        response.setContentType("text/html");
        PrintWriter pw=response.getWriter();
        Cookie cookie1=new Cookie("09221A0501","09221A0501");
        Cookie cookie2=new Cookie("09221A0502","09221A0502");
        Cookie cookie3=new Cookie("09221A0503","09221A0503");
        Cookie cookie4=new Cookie("09221A0504","09221A0504");
        cookie1.setMaxAge(60*60);
        cookie2.setMaxAge(60*60);
        cookie3.setMaxAge(60*60);
        cookie4.setMaxAge(60*60);
        response.addCookie(cookie1);
        response.addCookie(cookie2);
        response.addCookie(cookie3);
        response.addCookie(cookie4);
    }
}



Friday, 26 August 2011

SPM ASSIGNMENT QUESTIONS FOR I MID EXAM

1. What is adversarial stakeholder relationship?
2. What are the five necessary improvements for the waterfall model explain?
3. describe the various dimensions of scheduling? how dimensions are helpfull in improving software economics?
4. Explain Peer Inspections?
5. Explain SDP plan?
6. Discuss about Test artifacts?
7.Discuss about pragmatic artifacts?
8. explain about iteration workflows?