How to call servlet from jsp

i m trying to call it from jsp using
<a href="../purchaseP?orderno=<%=pno%>"><%=pno%></a>
but its giving error..
type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

i m trying to call it from jsp using
<a href="../purchaseP?orderno=<%=pno%>"><%=pno%></a>
but its giving error..
type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed
for the requested resource (HTTP method GET is not
supported by this URL).Are you implementing the doGet or doPost method in your servlet? If you are calling from a hyperlink then it needs to be implementing the GET method. To access the POST method use a html form.

Similar Messages

  • How to call Servlet from jsp page and how to run this app using tomcat..?

    Hi ,
    I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
    Please tell me how to do this into jsp page..?
    Also i wanted to execute this application using tomcat.
    Please tell me how to do this...? what setting are required for this...? what will be url ..??
    Thanks.

    well....my problem is as follows:
    whenever i type...... http://localhost:8080/appName/
    i am getting 404 error.....it is not calling to login.jsp (default jsp)
    but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
    Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
    In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
    plz help me.

  • Urgent: how to call servlet from JSP

    I have a working servlet which returns a table in html format. I also updated the web.xml file according to the information I got from the previous message. My problem is how to correctly invoke the servlet in the JSF. I tried the following ways:
    <jsp:include page="/report">
    <jsparams>
    <jsparam name="srcDev" value="#{Page1.srcDevice}"/>
    <jsparam name="tgtDev" value="#{Page1.tarDevice}"/>
    <jsparam name="format" value="complete"/>
    </jsparams>
    </jsp:include>
    and
    <frame src="/report?param1=val1&param2=val2" name="body" frameborder="YES" scrolling="YES" bordercolor="#999999" noresize>
    both doesn't work.I am able to run the servlet within a html form. I just don't know what's the right syntax for calling the servlet inside a JSP page in JSF.
    Can anybody help me?
    Thanks,
    Christine

    Hi Christine,
    This forum is exclusively for Sun Java Studio Creator related issues.
    In case you are using Creator then you can find a sample application named RedirectionExample which makes use of a servlet and would be of help to you. You can find the tutorial on the following page:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    Cheers
    Giri :-)

  • How to call servlet from jsp in portal applicaton...??

    JDeveloper - 11.1.1.6.0
    Hii all, i am working on an portal application in which i have added my adf application as portlet..
    in this adf application i am having an jsp page on the popup
    the action of this jsp page is set to an servlet
    <form id="form1" action="servlet/UpdateServlet">
    <input type="text" name="test"/>
    <input type="submit" value="SUBMIT"/>
    </form>
    But when i click on submit button, the servlet is not being called..
    The servlet is -
    public class UpdateServlet extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    public void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException,
    IOException {
    String value1 = request.getParameter("test");
    System.out.println("one : "+value1);
    Any help on this
    Thanks
    Edited by: 938480 on Oct 3, 2012 1:56 AM

    Which application server you are using.
    I am using JRUN SERVER.
    For me it is very easy
    I have to put my servlet in web-inf/classes/xx.class.
    Then i can run like
    http://localhost/xx.
    Let me know which server u are using.

  • Wot all ways are there to call servlet from jsp

    hi all
    i want to know wot all methods are available
    so that i can call servlet from jsp
    the one which i know is using RequestDispatcher
    wot are others ?
    thanx

    hi all
    i want to know wot all methods are available
    so that i can call servlet from jsp
    the one which i know is using RequestDispatcher
    wot are others ?
    thanxhi here are few ways... to call servlet from jsp...
    these are just generic syntax.
    Form:     
    <form action="ServletPath">
    Link:     
    Directives & Action tags :
    <%@ page import="ServletPath" %>
         <%@ taglib uri="ServletPth" %>
         <jsp:include page="ServletPath">
         <jsp:forward page="ServletPath">
         <jsp:useBean class="ServletPath"> (Not sure about this useBean)
    hope you got your answer.
    regards,
    immu

  • Do not know how to call Servlet from a JSP???

    How do I call a Servlet from a JSP page?
    I have an JSP page that does a few things but when there is an error I need the JSP page to call a Servlet but do not know how to do it.
    I want to call a ServletFaillogin from a JSP page how can I do it?
    <html><head>
    <title> Login Page </title>
    </head>
    <body>
    <%@ page import= "portal.* " %>
    <jsp:useBean class="portal.PortalSystem" id="bean" scope="session" />
    <% try
      String servername = request.getParameter("servername");
      String username = request.getParameter("username");
      String password = request.getParameter("password");
      bean.Connect(servername, username, password);
    catch(Exception e)
       //******Here I need help *********
       action="http://localhost:8080/test/servlet/ServletFaillogin";
    %>
    <h1> You have successfully logged in. </h1>
    </body></html>

    I have changed the code but get error, why??
    I think it could be due to the way classes are located,
    All my HTML and JSP pages are at:
    C:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\jsp\portal-project
    The class ServletFaillogin is located here:
    C:\tomcat\jakarta-tomcat-3.3.1\webapps\myJSPs\WEB-INF\classes\portal
    What am I doing wrong, please help???
    <html><head> <title> FTP Login </title> </head>
    <body>
    <%@ page import= "portal.* " %>
    <jsp:useBean class="portal.PortalSystem" id="bean" scope="session" />
    <%      try
               String servername = request.getParameter("servername");
               String username   = request.getParameter("username");   
               String password   = request.getParameter("password");
               bean.Connect(servername, username, password);
            catch(Exception e)
               response.sendRedirect("http://localhost:8080/myJSPs/servlet/ServletFaillogin");
    %>
    <h1> You have successfully logged in. </h1>
    </body></html>

  • Very urgent: call servlet from JSP

    Hello,
    I'm facing a problem in invoking a servlet from a JSP having the JSF components.
    The application has a text field to implement ajax for search functionality in the database .I have written a servlet to make the database connection and fire the querry.
    Ajax implementation in a js file is called on every keyup event in the jsp file,and
    a call is given to the servlet from the ajax methode.
    The function in the js file is as follows:-
    function getPersonByFirstNameXML( firstName ) {
        if (!firstName) {
            clearPersonByFirstNameXML();
        } else {   
            var url = BASE_URL + "/servlet/get_PersonsXML";
            alert(url);
            return new AJAXRequest("post", url, "firstName=" + encode(firstName), processGetPersonByFirstNameXML);
    }Im getting the myAJAX.status value as 500.
    I think I'm not able to access the servlet properly.
    what changes do i need to make in the we.xml file ?
    and what should be the url to be passed.
    Please provide me a sloution to the above problem as it is very urgent else if anybody is aware of a readymade JSF componet with search functionality freely available please let me know.
    PS:
    The sample application named RedirectionExample which makes use of a servlet and would be of help to you. You can find the tutorial on the following page:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    is not available as stated in some of the suggestions by Author: mayagiri
    Thanks for any help.
    Abhi

    the status 500 generally means either HTTP server internal error or that execution of CGI script or servlet aborted with error.
    It can be reasonably supposed that the request reaches the servlet, ie. that "url" value points to some existing servlet, otherwise most probably the status value would be 404.
    To test that the servlet is working i'd try to access it using some simple html page with form like this (with {BASE_URL} replaced by real value):
    <form method=post action={BASE_URL}/servlet/get_PersonsXML>
    <input type=text name=firstName>
    <input type=Submit>
    </form>

  • How to run servlet from JSP page

    A simple JSP page,where I will put a button.And on clicking..it will invoke the servlet and the servlet will send the result to the jsp page...
    Please give the instructions with examples...
    Thanks in advance...

    hi,
    Create a jsp inside webapps/root
    <a href="./howtocode" > click to call servlet </a>and follow the steps
    http://forum.java.sun.com/thread.jspa?threadID=5202830

  • Problem calling servlet from JSP

    Hi All,
    I am running Tomcat 4.1.31 + Apache 2.0.54 for a web app. I have a jsp in a folder in my context root that is calling a servlet. My web.xml looks like this
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE web-app (View Source for full doctype...)>
    - <web-app>
    <display-name>Web Application</display-name>
    - <!-- +===========================================+
    | SERVLET: Controller |
    +===========================================+
    -->
    - <servlet>
    <servlet-name>Controller</servlet-name>
    <description>Testing Servlets</description>
    <servlet-class>servlets.Controller</servlet-class>
    <load-on-startup />
    </servlet>
    - <servlet-mapping>
    <servlet-name>Controller</servlet-name>
    <url-pattern>/Controller</url-pattern>
    </servlet-mapping>
    </web-app>
    and my jsp is as below:
    <form name="loginForm" id="loginForm" action="/Controller" method="post">
    <table border="1" cellpadding="5" width="300">
    <tr>
    <td>User Id </td>
    <td><input type="text" name="userid" size="20" maxlength="15"/></td>
    </tr>
    <tr>
    <td>Password</td>
    <td>
    <input type="password" name="passwd" size="20" maxlength="10"/>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <input type="submit" name="submit" id="submit" value="Submit"/>
    </td>
    </tr>
    </table>
    <input type="hidden" name="action" id="action" value="login"/>
    </form>
    However, this doesnt work at all. Whenever I hit the submit button I get a 404 File not Found error.
    I have to give the entire url starting with the context root in the JSP for the servlet to work. Is that how it is supposed to work?? I was under the impression that once everything is defined correctly, Tomcat will figure out that the JSP and the servlet belong to the same app and get it from there.
    Can anyone help me please???
    Let me know if anything is not clear enough.
    Thank you!
    amrutaa

    Actually this is just an example app ... but I am going to have other jsps that will call the controller servlet ..
    Thanks a lot for your help. I really appreciate it.
    What stumps me is that the call to the servlet was working day before yesterday and yesterday it just wouldnt!
    and I am sure I touched only the servlet in the meanwhile + restarted Apache as well as Tomcat.
    Thanks again!
    -Amruta

  • C:import tag - Query string while calling servlet from JSP

    Hi,
    From my JSP I am calling a servlet to write back to the response stream of the JSP. From the JSP i am trying to pass some values into the query string as follows
         <%
         String strGetParameters = "/servlet/MyServlet?path=" + strPath;
          %>
         <pre><c:import url="<%=strGetParameters%>" /></pre>In the servlet I try to get the path from the query string by using
    request.getParameter("path")But in the servlet the query string doesnt have the "path" parameter that I added in the strGetParameters string (in the JSP).
    Am i missing something? Do i have to use something else or do something else?
    Any help is appreciated.

    I've taken some time to do a simple test and it just works.
    Here is the test code, it was tested in Java EE 5 + JSTL 1.2 + Tomcat 6.
    JSP<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <html>
        <head>
            <title>Test</title>
        </head>
        <body>
            <pre>
                <c:import url="myServlet?param1=foo&param2=bar">
                    <c:param name="param3" value="meep" />
                    <c:param name="param4" value="waah" />
                </c:import>
            </pre>
        </body>
    </html>MyServlet (mapped on "/myServlet")package mypackage;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class MyServlet extends HttpServlet {
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
            String param1 = request.getParameter("param1");
            String param2 = request.getParameter("param2");
            String param3 = request.getParameter("param3");
            String param4 = request.getParameter("param4");
            String output = param1 + ", " + param2 + ", " + param3 + ", " + param4;
            response.getOutputStream().write(output.getBytes());
    }All parameters gets printed.

  • How to call reports from JSP/HTML application

    Hi,
    We have a web application developed in JSP, I'd like to use Oracle Reports writer to generate reports (Since our back office application is developed using Oracle forms and Reports - 6i).
    I don't know how to place a request to Oracle Reports server and view the output. Can someone please help me with this.
    Thanks in advance.
    Best Regards,
    Karthik

    Hello Karthik,
    You have a web application developed in JSP. In that you are calling Reports though URL through your JSP.
    User views the source of the HTML page, in browser which is the result of execution of JSP. So Client will see the
    HTML output, but not the real JSP.
    Still if you donot want to hard code the user/password in file, have a form and ask client to enter user/password.
    Or you can combine your JSP with other Java components , like Java bean or Servlets to get user/password at run time.
    With Regards
    Sachin

  • Not able to call servlet from jsp

    I have a jsp from which i'm calling a servlet code is given below:-
    <html>
    <body>
    <jsp:forward page="/doubleHello" />
    </body>
    </html>
    my web.xml is:-
    <web-app>
    <display-name>HelloServlet</display-name>
    <description> HelloServlet </description>
    <servlet>
    <servlet-name> ServletCallingEjb </servlet-name>
    <servlet-class> myServlet.HelloServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> ServletCallingEjb </servlet-name>
    <url-pattern> /doubleHello </url-pattern>
    </servlet-mapping>
    </web-app>
    My servlet looks like:-
    package myServlet;
    import myEjb.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    public class HelloServlet extends HttpServlet
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         out.println("<html><head><title>Hello from Servlet</title></head>");
         out.println("<body><h1>Hello from hello servlet!</h1></body>");
    out.println("<br>";
    out.println("</html>");
    But when i run the code i'm getting page cannot be displayed. Please please suggest what am i doing wrong???
    Message was edited by:
    Samrat Kar

    Reframing the question
    I have a jsp from which i'm calling a servlet code is given below:-
    <html>
    <body>
    <jsp:forward page="/doubleHello" />
    </body>
    </html>
    my web.xml is:-
    <web-app>
    <display-name>HelloServlet</display-name>
    <description> HelloServlet </description>
    <servlet>
    <servlet-name> ServletCallingEjb </servlet-name>
    <servlet-class> myServlet.HelloServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> ServletCallingEjb </servlet-name>
    <url-pattern> /doubleHello </url-pattern>
    </servlet-mapping>
    </web-app>
    My servlet looks like:-
    package myServlet;
    import myEjb.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import java.io.PrintWriter;
    import java.io.IOException;
    public class HelloServlet extends HttpServlet
    public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter(); out.println("<html><head><title>Hello from Servlet</title></head>");
    out.println("<body>Hello from hello servlet!</body>");
    out.println("</html>"); } }
    But when i run the code i'm getting page cannot be displayed. Please please suggest what am i doing wrong???

  • How to call  servlet from applet residing in Oracle9i forms bean area.

    Dear Members
    I have an applet which is calls a servlet for database operations. If access this from a browser it works fine as the applet is signed. But When i place this applet in a bean area of Forms in Oracle 9i. It gives access control exception. Can anyone help me, as i feel this problem is with oracle9i forms.

    Dear Members
    I have an applet which is calls a servlet for database
    operations. If access this from a browser it works
    fine as the applet is signed. But When i place this
    applet in a bean area of Forms in Oracle 9i. It gives
    access control exception. Can anyone help me, as i
    feel this problem is with oracle9i forms.As far as I recall - Oracle 9i forms is operating on a top of another special/internal servlet. I can't really recall, since I've been working with Oracle 9i forms 2 yrs ago. So total procedure looks like following:
    applet -> Oracle 9i Forms servlet -> my servlet
    instead of
    applet -> my servlet
    I think this is an actual reason why your signed applet can't work with your servlet.
    Oracle 9i servlet has a number configuration files, I think among them you should change smth to get your construction working. Another approach would be to use servlet filtering before calling Oracle 9i servlet
    Hopefully it will help
    Paul

  • Calling servlet from a java program

    Hi
    I need to call a servlet's doPost() method from a java program. I have a specific situation, where I need to call servlet from a java program. DUring this call I need to pass a file and two string to the servlet. Servelt after receiving the file and string uploads the file to the server at a specified location. I am stuck up as how to call servlet from a java program instead of a HTML or JSP.
    Can anyone help me to start with this.
    any suggestion is welcome.

    You have to establish a URLConnection with servlet from your java program.
    URL servletURL = new URL("http://localhost:8080/Myservlet?str1=abc&str2=def");
    URLConnection servletConnection = servletURL.openConnection();you can get the objectOutputStream
    ObjectOutputStream oos = new ObjectOutputStream (servletConnection.getOutputStream());
    oos.writeObject(your file object);-------------------------------------------------
    In the servlet u can get the strings using request.getParameter("str1");
    In the servlet u can get the strings using request.getParameter("str2");
    file = new ObjectInputStream (request.getInputStream()).readObject()a lot of resources are available on this ...
    hope this helps :)

  • Calling JApplet from jsp

    Hi,
    Can any one tell me how to call JApplet from JSP? I am using <jsp:plugin>
    tag but it is not working.

    use the jsp:plugin tag like this in your jsp page..
    <jsp:plugin  type="applet"
         code="appletclsname.class"
         codebase="ourapplets"
         jreversion="1.5"
         width="400px"
         height="200px">
    </jsp:plugin>

Maybe you are looking for

  • LaserJet_600_M602_NW_access

    hello i have LaserJet 600 M602. how to setup 802.1x auth? when i enter name, password, server address and then i click on submit, nothing happens. i can see "successful" but 802.1x auth is still inactive. also i have Network access protection server

  • EDI 850 Inbound file in ASC X12 format

    Does anyone happen to have a sample 850 Inbound file I can test with our new implementation of e-commerce? Thanks in advance for your help!

  • How to avoid, tab's opening in other language.

    Firefox uses Dutch as the standard language in my case. But when I open a 2e, a 3e, etc. tab, it switches over to French. Is that to avoid? Thank you, HWtn

  • OpenCL support on PC?

    Hello. I'm in the middle of building a new PC and getting ready for CS6. I was pretty sure that my new gfx card would be the GXT 680 from Nvidia. But then I saw this test: http://www.tomshardware.com/reviews/geforce-gtx-680-review-benchmark,3161-15.h

  • Moving average price (MAP) became Zero(0) for one material

    Gurus, Please tell me what could set MAP to zero for a material? Thanks, Kishore