servlet problem

servlet problem

when i have perform action on submit button then there is no call servlet in my action i have done every effort in this programe plz give me solution .
View Answers

March 19, 2010 at 11:24 AM

Hi Friend,

Put your jsp file in web application folder and servlet in classes folder of apache tomcat. The web application folder should be under webapps folder of apache tomcat. Here examples is our web application folder.

1)index.jsp:

<HTML>
<FORM method="post" action="./ServletExample">;
<TABLE>
<TR><TD>Name:</TD><TD><input type="text" name="name"></TD></TR>
<TR><TD>Address:</TD><TD><input type="text" name="address"></TD></TR>
<TR><TD><input type="submit" value="Submit"> </TD></TR>
</FORM>
</HTML>

2)ServletExample.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ServletExample extends HttpServlet{
public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String name=req.getParameter("name");
String address=req.getParameter("address");
out.println(name);
out.println(address);
}
}

3)In web.xml do the following:

<servlet>
<servlet-name>ServletExample</servlet-name>
<servlet-class>ServletExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletExample</servlet-name>
<url-pattern>/ServletExample</url-pattern>
</servlet-mapping>

For more information,visit the following link:

http://www.roseindia.net/servlets/index.shtml

Thanks









Related Tutorials/Questions & Answers:
Servlet problem
connectivity code it works but problem is with servlet page. My servlet code...Servlet problem  Hello, I am very shocked about this mysterious problem from last three month and now i hope rose india developers
servlet problem
servlet problem  wheni m deploying an servlet application im getting trouble context [/filename] startup failed due to previous error in tomcat 6.0.
Advertisements
problem in servlet program
problem in servlet program  Dear Sir, I have a problem to insert the Blob type data like as video file, audio file in the database using Servlet and html code
Servlet Problem - JSP-Servlet
Servlet Problem  Hii I am Ajay . I am makin g a project in java using servlets. I have a database in which I have stored images along with some other info(Name, address type). I want to display that info in text form along
Java Servlet Problem - JSP-Servlet
Java Servlet Problem  I have a servlet class that implemets..., but in the attributeReplaced() method, i want to perform a redirect to another servlet... method. Please help!!  Hi friend, Please explain problem
Servlet Problem proceed - JSP-Servlet
Servlet Problem proceed  Thank you fro your reply. But I couldnt find any serious error.Please see this. User is the package classes/User... problem then read more details. http://www.roseindia.net/servlets
problem running a servlet on tomcat.
problem running a servlet on tomcat.  i have followed the steps given... to run my servlet that is placed in the directories as it has been mentioned here... be the problem? please help me out
Servlet problem - JDBC
Servlet problem  Hii Everyone, I m Ajay. I m making a project using... SQL 2000 database and I have developed a servlet that accepts input from user but however. It gives problem sometimes while at others it works perfectly. I m
Problem in Servlet - Servlet Interview Questions
Problem in Servlet  Sir, I have pointed everything in web.xml, path class path etc.. empController is my main servlet program and I called in form.... then some exception ..Servlet Exception: empContrller is not a servlet pgm
logout problem.. - JSP-Servlet
logout problem..  hi... first of all thanks for ur... but their is some problem with the the logout,i m not able to logout when... done in the code i have used session object in project's servlet and jsp
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  
problem in programming - JSP-Servlet
problem in programming  Hi! I am new with jsp. I am facing a problem in programming to calculate the time interval between login time and logout time of user
pagination problem - JSP-Servlet
using servlets in that i called a these methods,to call this servlet i created a html file i wrote one form to call this servlet. In this servlet i used doget...(),my problem is that where i have to put & how to do pagination? my code
pagination problem - JSP-Servlet
using servlets in that i called a these methods,to call this servlet i created a html file i wrote one form to call this servlet. In this servlet i used doget...(),my problem is that where i have to put & how to do pagination? my code
servlet problem - Servlet Interview Questions
servlet problem   when i have perform action on submit button then there is no call servlet in my action i have done every effort in this programe... application folder and servlet in classes folder of apache tomcat. The web application
servlet code problem - JSP-Servlet
servlet code problem  This is my JSP code index.jsp Sync... here!!!..., i want to pass the texbox value and file to servlet im stuck with this error plzz help me..., in servlet if i use request.getParameter() its
servlet code problem - JSP-Servlet
servlet code problem  This is my JSP code index.jsp Sync Data Sync Data Please use the following input box to upload file or enter... to servlet im stuck with this error plzz help me..., thanks in advance....  
Java Problem - JSP-Servlet
Java Problem  What are the steps to run a java Servlet program.with examples  Hi Friend, Please visit the following link: http://www.roseindia.net/servlets/index.shtml Thanks
arraylist problem - JSP-Servlet
my code once again only in which i m facing the problem. /* * To change... servlet request * @param response servlet response...); } } this is giving an output in servlet page like: DST_Name: Code TeamLeader
Servlet compilation problem - Java Beginners
Servlet compilation problem  hi, m a beginner to servlet world... i m facing problem in servlet compilation problem.. i have set the classpath of servlet-api.jar . m using tomcat 6.0 i m unable to compile my servlet program
tomcat problem - JSP-Servlet
perfectly. Kindly let me know what is the problem at an earliest. Thanking... found your problem.. http://www.roseindia.net/web-application-server/tomcat
arraylist problem - JSP-Servlet
and POST methods. * @param request servlet request * @param response servlet response */ /* * To change this template, choose Tools.... It would be good for me to provide you the solution if problem is clear. Thanks
jsp problem - JSP-Servlet
working but my problem is size of image. so can u just help?? code..."); } else{ pw.println("problem in image insertion
jsp problem - JSP-Servlet
working but my problem is size of image. so can u just help?? code..."); } else{ pw.println("problem in image insertion
JSP Problem - JSP-Servlet
JSP Problem  Hi, I have problem,this is my senario I have one jsp,this jsp having the 3 fields.let me take 3fields userName,emailAddress,phoneNumber and two buttons(AddUser and Submit). Here i want to add 5 Users
logout problem?? - JSP-Servlet
logout problem??  sir, the logout code which u have send is not the proper solution coz,by using this code the browser get closed which shuold not happen.to logout properly i think we should empty or clear the browser
coding problem - JSP-Servlet
coding problem  dear sir i m very new to JSP sir i m getting problem in dynamically changing the option of combobox from database(ms acess) .and after that option being selected for that the record from the databse should
resultset problem - JSP-Servlet
resultset problem  hi I have one problem with resultset? ResultSet rs=st.execute("select subjname,staffname from staffdetails"); while(rs.next()) { st.executeUpdate("update CSEFIRSTYEARTIMETABLE set p2
Array problem - JSP-Servlet
.. Bur my problem is that if the pop up window contains only 1 record
servlet program problem - Java Beginners
servlet program problem   i used ur servlet example prg with xml file of helloworld program and i run dat program in tomcat, it shows only... file to run it  Hi Friend, Please clarify your problem. Thanks
Tomcat installation problem - JSP-Servlet
Tomcat installation problem   Hello I have installed Tomcat and my startup and shutdown programs are working but the problem is i couldnt open...:\apache-tomcat-6.0.16; 2) Put the servlet-api.jar into lib folder of apache tomcat
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName...=con.createStatement(); ^ i am confused what is the problem
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatcâ?¦ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatcâ?¦ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
Servlet Problem - Java Interview Questions
Servlet Problem  I need to get an alert message when the submit button is clicked again while processing... how is it possible...?? Thanks in advance
problem in jsp programming - JSP-Servlet
problem in jsp programming  Write a JSP program which displays a webpage containing arrival of new items within a particular month in the different... in solving the problem : Connection with mysql database
java validation problem - JSP-Servlet
to do this? Can anyone gives the answer for this problem? Thanks in advance... problem. Here is the link http://www.roseindia.net/jsp/user-registration-form
PROBLEM IN ACCESSING JSTL - JSP-Servlet
PROBLEM IN ACCESSING JSTL   hii i m vikram ... i am using jsp application with tomcat 4.1 .and i want to use JSTL in my jsp page ...so how can i use JSTL in my page .. and i install jakaerta-taglibs-standard-1.1.2 in directory
problem at the time of execution - JSP-Servlet
problem at the time of execution  when i was running web applications the exception i.e 404 resource is not available what it means and where it occures what is the solution   Hi Friend, This error occurs when
problem in insert query - JSP-Servlet
problem in insert query  Hi! I am using this statement for data insertion into table but data is not moving only null passed and stored... problem plz give full details with source code and visit to : http
jsp code problem - JSP-Servlet
jsp code problem  Hi, I have employee details form in jsp. After validate all the fields, it will update the database, then move to next form. I have a problem with open the next form. plz, help me. thanks,  Hi
Image problem Urgent - JSP-Servlet
Image problem Urgent  Respected Sir/madam, I am R.Ragavendran.. Actually I got your coding.. But This code is not enabling the user to click and change the image.. I request you to remember the code which you have
Simple problem to solve - JSP-Servlet
Simple problem to solve  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your kind and timely help for the program I have asked.... But in that I am facing a very very minute problem. The alert boxes are displayed
Problem with Instant Messaging - JSP-Servlet
Problem with Instant Messaging  I am creating a web application using JSP which enables users to chat using JMS. I need to know how to know the solution to the following situation: user1 and user2 are chatting with each
Session Problem in JSP - JSP-Servlet
Session Problem in JSP  I have developed a online feedback form in JSP platform. I have created normal session in JSP page. It is running in my machine properly, but when I am trying to access it from another machine
Simple problem to solve - JSP-Servlet
Simple problem to solve  Respected Sir/Madam, I am.... But in that I am facing a very very minute problem. The alert boxes are displayed.../Regards, R.Ragavendran..   Hi Raghavendran, The problem is not so
Problem in downloading files - JSP-Servlet
Problem in downloading files  Hi, i have uploaded some files using its uploading successfully. but when downloading the same file, its giving exception as below org.apache.jasper.JasperException: getOutputStream() has
problem getting servlet:xmlHTTP.status=404 - Ajax
problem getting servlet:xmlHTTP.status=404   hi, ihave a text field... object.The problem is my script is unable to get the servlet in which i have... of the servlet, it gets it and teh xmlHTTP.status =404 condition becomes false.im using
JSP code problem - JSP-Servlet
of: Please can somebody rectify this problem........  
richtext editor problem in servlets - JSP-Servlet
richtext editor problem in servlets  Hi This is Hari, I am getting problem with RichTextEditor. I have Servlet in this have RichTextEditor. then i made sum modifications submitting the page The page not submiting (meens

Ads