Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: [Help] How can I call a servet from jsp

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Thanked 0 Times in 0 Posts

    Default [Help] How can I call a servet from jsp

    I created : index.jsp in Web Pages , and GetThreeParam.java in Source Package . I can not call GetThreeParam.java from the index.jsp . Please Help me


    * To change this template, choose Tools | Templates
    * and open the template in the editor.

    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    * @author Du
    @WebServlet(name = "GetThreeParam", urlPatterns = {"/GetThreeParam"})
    public class GetThreeParam extends HttpServlet {

    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    //String title = "Reading three request parameters";
    "<H1 Align=CENTER>" + "Reading three request parameters" + "</H1>\n" + "<UL>\n"
    + "<LI><B>param1</B>:"
    + request.getParameter("tx1") + "\n"
    + "<LI><B>param2</B>:"
    + request.getParameter("tx2") + "\n"
    + "<LI><B>param3</B>:"
    + request.getParameter("tx3") + "\n"
    + "</UL>\n+</BODY></HTML>");
    try {
    } finally {


    Document : index
    Created on : Oct 11, 2012, 2:55:43 AM
    Author : Du

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>

    <form method="post" action="GetThreeParam.java" >
    <div style="width: 1000px;">
    Collect three Parameter
    <div style="width: 150px;float: left;line-height: 30px">
    First Parameter<br>
    Second Parameter<br>
    Third Parameter<br>
    <div style="width: 850px;float: left;line-height: 30px">
    <input type="text" name="tx1"><br>
    <input type="text" name="tx2"><br>
    <input type="text" name="tx3"><br>
    <input type="submit"></input>


  2. #2
    Junior Member
    Join Date
    Apr 2013
    Thanked 0 Times in 0 Posts

    Default Re: [Help] How can I call a servet from jsp

    In form tag <form name=..... method=..... action="/servlet/servletname">

  3. #3
    Junior Member lostmemory's Avatar
    Join Date
    May 2013
    Thanked 0 Times in 0 Posts


    .java is source code file of java
    it can not be executed by jvm.
    u must register your servlet into web.xml
    and use it by url-pattern.

Similar Threads

  1. call by value and call by reference
    By Appu14 in forum The Cafe
    Replies: 1
    Last Post: September 2nd, 2012, 06:58 AM
  2. How to call tablle
    By matsnys in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 16th, 2012, 11:53 AM
  3. How to call table?
    By matsnys in forum Member Introductions
    Replies: 1
    Last Post: August 15th, 2012, 01:49 PM
  4. Call by Reference & Call by Value
    By Lokesh in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2011, 01:19 PM
  5. How to call int value from another class
    By IDK12 in forum Java Theory & Questions
    Replies: 7
    Last Post: January 14th, 2011, 09:18 PM