Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet JSP and Servlet did not run
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sakai
JSP and Servlet did not run
2 Answer(s)      4 years and 11 months ago
Posted in : JSP-Servlet



Advertisement
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
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
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
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.
how to run servlet
how to run servlet  Servlet run procedure for J2EE Software   Hi Friend, Please visit the following links: http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml http://www.roseindia.net/servlets
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
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
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 jsp file is to be saved into the web application folder.Let the file... For more information on JSP visit to : JSP Tutorials Thanks
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 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
how to compile and run servlet program
how to compile and run servlet program   hello sir/mam i hve installed tomcat5.5 version and also have jdk1.6.0_14 installed but not able to run it or compile i m doing it first tyme pls help me in sorting out this problem. i hve
how to run a vlc player in jsp
how to run a vlc player in jsp  how to run a vlc player in jsp
how to run a .exe file in jsp
how to run a .exe file in jsp  i want code for to run a .exe file in jsp
How to run a simple jsp page in tomcat???
How to run a simple jsp page in tomcat???  i am trying to run a simple jsp page in tomcat,i am having web.xml also in WEB-INF folder...\Tomcat 6.0\lib\servlet-api.jar using this ,i am able to run all servlet programs
JSP handle run-time exceptions
JSP handle run-time exceptions  How does JSP handle run-time... to have uncaught run-time exceptions automatically forwarded to an error processing... the browser to the JSP page error.jsp if an uncaught exception is encountered during
Jsp error when i run this a jsp file
Jsp error when i run this a jsp file  hi I got this error when i run the jsp file in IDE and outside also please help me java.lang.NullPointerException org.apache.jsp.insertjsp.jspInit(insert_jsp.java:22
Failed to run Online Quiz Application in JSP - JSP-Interview Questions
Failed to run Online Quiz Application in JSP   Hi, I have been following your following link to run the online quiz application, but I failed... you kindly document the steps in more details to run your application
platform(s/w requirements) for run jsp programs?
platform(s/w requirements) for run jsp programs?  in which platform jsp programms are run
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
run command prompt from jsp program
run command prompt from jsp program  Hi.... Is it possible to run a command prompt from jsp? If possible please help me with some code... Thanks & Regards vanchinathan.R
To run a jsp file automatically - IDE Questions
To run a jsp file automatically  Hi all, I am in need for the solution for - Can a JSP page can be made to run automatically when NetBeans IDE has been started. or we have to compile and run it automatically? I
The Currently Running Servlet is showing some Previously run Servlet's Output
The Currently Running Servlet is showing some Previously run Servlet's... for example, I have executed the ParameterServlet servlet where the output... am executing another different servlet, It is showing the same output
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
 

 

 

DMCA.com