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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


mohd arif
servlet problem
1 Answer(s)      4 years and 9 months ago
Posted in : Servlet Interview Questions


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 .

Advertisement
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
servlet problem  wheni m deploying an servlet application im getting trouble context [/filename] startup failed due to previous error in tomcat 6.0.
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
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
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 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
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
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
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
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  
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
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
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
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
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 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....  
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
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
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
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
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
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
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
 

 

 

DMCA.com