The below example explains the readers on how to write a web based application making use of redirect to transfer a http request to another page. Firstly, a working Eclipse IDE should be in place and follow the steps below to create a Dynamic Form based Web Application.
|1||Create aDynamic Web Projectwith a nameHelloWeband create a packagecom.wisdomjobsunder thesrcfolder in the created project.|
|2||Drag and drop below mentioned Spring and other libraries into the folderWebContent/WEB-INF/lib.|
|3||Create a Java classWebControllerunder thecom.wisdomjobspackage.|
|4||Create Spring configuration filesWeb.xmlandHelloWeb-servlet.xmlunder theWebContent/WEB-INFfolder.|
|5||Create a sub-folder with a namejspunder theWebContent/WEB-INFfolder. Create view filesindex.jspandfinal.jspunder this sub-folder.|
|6||The final step is to create the content of all the source and configuration files and export the application as explained below.|
Below is the content of view file i.e., index.jsp. This page will send request to make use of redirect service which redirects the request to other service method and finally a final.jsp page will be displayed.
Following is the content of Spring view file final.jsp. This is the final redirected page.
Finally, following is the list of Spring and other libraries to be included in your web application. You simply drag these files and drop them in WebContent/WEB-INF/lib folder.
Once the source and configuration files are created export the application. Do right click on the application and Export > WAR File option and save SpringWeb.war file in Tomcat’s webapps folder.
Start the Tomcat Server and using a standard browser check if you are having access to other web pages from webapps folder. Try the URL http://localhost:8080/SpringWeb/student and you must see the below result if everything is fine with Spring Web Application:
Submit the form by clicking “Redirect Page“ buttononce the required information is filled to get redirected page. You must see the below result if everything is fine with Spring Web Application:
Spring MVC Framework Related Interview Questions
|J2EE Interview Questions||Hibernate Interview Questions|
|MVC Framework Interview Questions||Framework7 Interview Questions|
|Maven Interview Questions||JUnit Interview Questions|
|Log4j Interview Questions||Spring MVC Framework Interview Questions|
|Java J2ee Architect Interview Questions||Spring Boot Interview Questions|
|Spring Batch Interview Questions||Spring Security Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.