JSP and Servlet did not run

JSP and Servlet did not run

View Answers

December 16, 2009 at 10:27 AM

Hi Friend,

Put your servlet in WEB-INF\classes folder and do the following:

1)index.jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Simple Use of Servlet and JSP</title>
</head>
<body>
<h1>Conference Registration</h1>
<form action="../DispatchServlet" method="post"">
<h2>Name: </h2>
<input type="text" name="userName">
<h2>Status: </h2>
<input type="radio" name="status" value="student"> Student
<input type="radio" name="status" value="faculty"> Faculty <br/>
<input type="submit" value="Submit">
</form>
</body>
</html>

2)DispatchServlet.java:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DispatchServlet extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String status=request.getParameter("status");
int orgFee = 500;

if (status != null && status.equals("student")) {
int studentFee = orgFee/2;
request.setAttribute("regFee", "" + studentFee);
request.getRequestDispatcher("/jsp/output.jsp").forward(request, response);
return;
}
else if (status != null && status.equals("faculty")) {
request.setAttribute("regFee", "" +orgFee);
request.getRequestDispatcher("/jsp/output.jsp").forward(request, response);
return;
}
}
}
3)web.xml:
<servlet>
<servlet-name>DispatchServlet</servlet-name>
<servlet-class>DispatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DispatchServlet</servlet-name>
<url-pattern>/DispatchServlet</url-pattern>
</servlet-mapping>

Thanks

December 17, 2009 at 2:38 AM

Hi,

Thanks for your reply - I noticed that you have changed in "DispatchServlet" from doGet to doPost?

I want it in doGet method.

Hope to hear from you soon.
Thanks.









Related Tutorials/Questions & Answers:
JSP and Servlet did not run - JSP-Servlet
JSP and Servlet did not run  I tried to run this program but when I... --------- Simple Use of Servlet and JSP... the following: 1)index.jsp: Simple Use of Servlet and JSP Conference
how to run servlet - JSP-Servlet
how to run servlet  pls give me comlete procedure to run the servlet on apache-tomcat 6.0.16 how can i set my classpath, java_home etc. also where i have to save my servlet program and how it compile and then run on web browser
Advertisements
how to deploy and run jsp - JSP-Servlet
how to deploy and run jsp  hi anybody plz tell how to deploy and run jsp. and where jsp and html files save in web-inf or any where?  Hi...- WEB-INF-classes | | root web.xml You save the jsp or html
how to run jdbc in jsp program - JSP-Servlet
how to run jdbc in jsp program  i want to use sql server 2005 in jsp program to store data.i know how to run simple program but this program i tried... visit the following links: http://www.roseindia.net/jsp/submit-comments
Unable to run the jsp page - JSP-Servlet
Unable to run the jsp page  Expert:Naga Hi, I need solution this program. In cart.jsp I printed the total amount of the products then the next page is shipping and billing details and the next page is payment details. What
to run html code in web browser - JSP-Servlet
to run html code in web browser  how to run jsp file which calls html file on web browser??  Hi Friend, Try the following code: 1)form.jsp: Enter Name: 2)welcome.html: Add Profile Edit
Unable to run jsp files on internet explorer - JSP-Servlet
Unable to run jsp files on internet explorer  Hi, I am Akhilesh Shrivastav. I am new to jsp and a new member of this site. My problem is i wrote a small jsp program stored in the Web-Apps folder of Apache Tomcat. But i
How Run JSP in Apache TomCat Server? - JSP-Servlet
How Run JSP in Apache TomCat Server?  How to Run JSP in Apache Tomcat... pasted my hello world example of JSP in the Jsp-example directory. and tried. ... the Jsp-example\WEB-INF\classes directory and put the class files of your example
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
How to save run time created text-file on a disk using jsp/servlet?
How to save run time created text-file on a disk using jsp/servlet?  I have a JSP page with save button.In that I created the file(e.g a.txt) at run-time,when I click on the save button,it will ask where to save the file
jsp/servlet - JSP-Servlet
jsp/servlet  How to create and save the excel file on given location using jsp/servlet?  hi Geetanjali, Read for more information, http://www.roseindia.net/jsp/poi/excelPOI.shtml Thanks
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value.   Hi Friend, Please visit the following links: http://www.roseindia.net/tutorial/servlet/passParameters.html
jsp and servlet
jsp and servlet  what is the difference between jsp and servlet ? what is the advantages and disadvantages of jsp and servlet
servlet and jsp
servlet and jsp  how to connect an jsp and an servlet without connecting to database
JSP - JSP-Servlet
JSP & Servlet Example Code  Need example of JSP & Servlet
unable to run servlet
-mapping> 6)Compile your servlet. 7)Run Tomcat server by clicking... servlet. 7)Run Tomcat server by clicking the startup.bat file. This is located...-mapping> 6)Compile your servlet. 7)Run Tomcat server by clicking the startup.bat
servlet and jsp - JSP-Servlet
servlet and jsp  can any one give me jsp-servlet related project-its urgent- 1-chat application 2-bug tracking system 3-online shopping 4-online...://www.roseindia.net/jsp/bank.shtml Thanks
Servlet - JSP-Servlet
Servlet and Java Code  Example and source code in Servlet and JSP
servlet/jsp - JSP-Servlet
servlet/jsp  hi, get me the source code to upload all file formats in servlet/jsp plaese help me as soon as possible its urgent!!! by saravanan.k  Hi friend, Code to help in solving the problem
how to run servlet
how to run servlet  Servlet run procedure for J2EE Software   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml http
Servlet - JSP - JSP-Servlet
Servlet - JSP  i used arraylist in servlet as shown ArrayList total = new ArrayList (); ... total.add(k[i]); session.setAttribute("efg",total); when I code this like in my jsp <%ArrayList<Integer> data= new
servlet and jsp - JSP-Servlet
servlet and jsp  Hello folks, I am very new JDBC. I am doing a project on java messaging service on the part of the project we are using JDBC. In my...   write in the jsp form action="path of servlet" and wirite
servlet and jsp - JSP-Servlet
servlet and jsp  Hi friend, please show one sample program, how to connect jsp and servlet using backend a ms-access.  Hi friend,<%@ page language="java" import="java.sql.*,java.util.*,java.text.*"
JSP Parse did not work - Java Server Faces Questions
JSP Parse did not work  I have these codes: =========================================================================== index.jsp: "Poor" "Good" "Very Good" "Excellent" DropDown.java: import java.io.
jsp/servlet - JSP-Servlet
jsp/servlet  Hello ! How can we call a servlet on a link on html page like a href="servletname"> Call Servlet Is it possible?   Hi friend, I am sending simple application using servlet. This is form
how to run jsp appication in eclipse
how to run jsp appication in eclipse  after setting the tomcat in eclipse, i m trying to run jsp page, but the pop up has come that "selection did not contain any resources that can run on server". plase tell me i m new to handle
run jsp file
run jsp file  how to run the jsp file in varies web servers  ... the class path also. The jsp file is to be saved into the web application folder.Let...:8080/examples/abc.jspADS_TO_REPLACE_2 For more information on JSP visit to : JSP
java (servlet) - JSP-Servlet
java (servlet)  how can i disable back button in brower while using servlet or JSP
How to compile and run the JSP
How to compile and run the JSP  Hi Kindly tell me how to run and compile JSP small Program using Tomcat as webserver. I created small program HELLO JSP in HTML and compile the program but it is saying Class o r interface
Jsp-Servlet
Jsp-Servlet  how can i display the values in jsp pages as list from servlet ? can you help me out plz ? thanks
JSP,Servlet - JSP-Servlet
JSP,Servlet  How can i pass a list of objects from jsp to an Action? Please help me to do
jsp/servlet - JSP-Servlet
jsp/servlet  Hello friends ! I want to create columns in a table at run time everyday. I am using mysql database.how should I do it? thanks in advance  Hi friend, Plz explain your problem in details to solve
Servlet-JSP population - JSP-Servlet
Servlet-JSP population  Hi, I got my code worked. now I have another task. My jsp page on submit gets redirected to another servlet update cart... = request.getParameter("Box1"); But how to run it for a list of "i". same is the case
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP with one text field to enter the URL and a submit button.On clicking the submit button, send the request to a servlet .Once the servlet receives the request, it need
jsp servlet
jsp servlet  i dont know how to write a code to Create a JSP with one text field to enter the URL and a submit button.On clicking the submit button, send the request to a servlet .Once the servlet receives the request, it need
JSP & Servlet - JSP-Servlet
JSP & Servlet  In the process of login validation. i'm entering the username correct and pass wrong. when using response.sendRedirect() a new req... help me with coding ? i'm just a beginner with JSP and sServlets
JSP & Servlet - JSP-Servlet
JSP & Servlet  Its an IBM Question In the process of login validation. i'm entering the username correct and pass wrong. when using... is wrong ? can any one help me with coding ? i'm just a beginner with JSP
jsp-servlet - JSP-Servlet
jsp-servlet  what is the problem with using microsoft access as database? The sample example, i got from you is: database:mysql. One of my java faculty said, we cannot use ms-access as database because it has some dis-advantage
servlet/jsp - JSP-Servlet
servlet/jsp  Thanks for ur feedback! But this program shows an error showing package.org.apache.commons.fileupload.servlet does not exists package.org.apache.commons.fileupload.disk does not exists
JSP - JSP-Servlet
JSP  if the jsp is converted into servlet which type of code genreted and it will exend which type of servlet?i want answer plzzzz replyyyyyyyyyy
Servlet - JSP - JSP-Servlet
Servlet - JSP  Here is my complete code. all my code is running with out any error. the for loop in servlet is running as many times as my checkboxes... Servlet Code: ---------------------- package com.servlet
JSP-Servlet
JSP-Servlet  Hi have created a JSP page and I need to print it when the user clicks on the print button. I have put a print button on the JSP page. Can somebody plz help me out with the Servlet page coding
JSP - JSP-Servlet
JSP  What is the meaning of extending JSP?  Hi friend, A jsp can be made to extend our own servlet instead of container generated servlet by using. <%@ page extend="package.className"> Thanks
clarification in jsp - JSP-Servlet
clarification in jsp  Hi did jsp supports post method to send values to next jsp? if possible how to use post method in jsp?and what is the default method(get/post) of jsp?  Hi Friend, Yes jsp supports Post
JSP run problem
JSP run problem  type Exception report message description... this request. exception org.apache.jasper.JasperException: Exception in JSP...) root cause java.lang.NullPointerException org.apache.jsp.bb_jsp
About jsp and Servlet - JSP-Servlet
About jsp and Servlet  Servlets are directly using java technologies. It is used in HTTP,FTP..etc, But Jsp only used in HTTP. Servlets are running fastly... Then why we moved from Servlet to JSP.. Pl Tell me the reasons
Jsp ,Servlet Problem - JSP-Servlet
Jsp ,Servlet Problem  hi, m new to jsp n Servlet. i really find ur... with oracle. it worked wonders. now i m starting jsp n servlet learning.. pls... to execute a servlet code on tomcat server... Thanking u... Santosh  
JSP with java/servlet - JSP-Servlet
(java bean or servlet) to fecth the database. Jsp would get the data from.../servlet-jsp-data-list.shtml Hope that it will be helpful for you. Thanks...JSP with java/servlet  Thanks Deepak for your answere to my previous

Ads