MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

Spring Programing laungage

Spring Projects

Spring Project 1

Login Example in Spring MVC
Previous Home Next

Directory Structure of Spring MVC application is given below:

step 1:

Create index.jsp file

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <title>Login Example in Spring MVC</title>
    <form action="login.bean">
    Name:-<input type="text" name="name"/><br/>
    Password:-<input type="password" name="password"/><br/>
    <input type="Submit" value="Login"/>


step 2:

Create web.xml file

<web-app id="WebApp_ID" version="2.4"
<display-name>Spring MVC Application</display-name>

step 3:

Create dispatcher-servlet.xml file

<beans xmlns=""
<bean id="viewResolver"
="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix">
<property name="suffix">
<bean id="loginController" class="com.r4r.LoginController" />
<bean class
<property name="mappings">
<prop key="/login.bean">loginController</prop>

step 4:

Create file

package com.r4r;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class LoginController implements Controller {
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String name=request.getParameter("name");
String password=request.getParameter("password");
if(name.equals("Mukund")&& password.equals("Singh")){
ModelAndView modelSuccess=new ModelAndView("loginPage");
modelSuccess.addObject("msgSuccess", name);
return modelSuccess;
ModelAndView modelError=new ModelAndView("errorPage");
modelError.addObject("msgError", "Invalid UserName and Password");
return modelError;

step 5:

Create loginPage.jsp file

<%@taglib uri="" prefix="c"%>
<h4>You are successfully Login</h4>
<h5>Welcome, <c:out value="${msgSuccess}"/></h5>

step 6:

Create errorPage.jsp file

<%@taglib uri="" prefix="c"%>
<h4><c:out value="${msgError}"/></h4>
<h4>Please try again</h4>


Previous Home Next