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.

Similar Messages

  • 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.

  • 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

  • How to print report from JSP Page

    Hi Everybody,
    I am developing a simple project in JSP with MS Access. I hav some tables and reports for them. I hav a JSP page which gets inputs from user and save it in the table. Its working fine. But my problems are,
    1) I hav a button called "SAVE & PRINT" in that bottom of the page, if i click that button, the currently entered data has to save in the table and the same data has to print from the MS Access report. I dont know how to print this report from JSP page.
    2) Another button called "REPRINT". If i click that button, it has to ask a number to print the report page, that number is nothing but a field in that report.
    Could anyone help me to solve this problem.

    Hi Everybody,
    I am developing a simple project in JSP with MS Access. I hav some tables and reports for them. I hav a JSP page which gets inputs from user and save it in the table. Its working fine. But my problems are,
    1) I hav a button called "SAVE & PRINT" in that bottom of the page, if i click that button, the currently entered data has to save in the table and the same data has to print from the MS Access report. I dont know how to print this report from JSP page.
    2) Another button called "REPRINT". If i click that button, it has to ask a number to print the report page, that number is nothing but a field in that report.
    Could anyone help me to solve this problem.

  • Calling Beans from JSP page

    hi,
    I tried to my best to call java beans from JSP page but it generate error that "unable to load class....", please help me that in which directory jsp file and bean *.class file reside, currently my setting are as follows.
    Note: I am using tomcat server and my jsp and servlet files are running seccessfuly, there is any special change in classpath for java beans? if any please tell
    My jsp file is in tomcat-->webapps-->jsp--><my file>
    My bean (*.class) file-->webapps-->Root-->web-inf-->classes--><my file>
    Pleae help me for the above problem.
    Mubashar ([email protected])

    According to J2EE standards:
    The web appl directory structure should be:
    WebAppRootDirectory
    |
    |---html, jsp, images etc
    |
    |---WEB-INF---
    |---classes--
    |---lib
    |
    |
    1) Make sure WEB-INF is in capital letters
    2) Place all ur beans in classes dir or sub-directory in
    classes
    3) In Tomcat place WebAppRootDirectory in webapps
    directory
    [email protected]

  • Trying to trigger a servlet from .jsp page on combo box change

    I have a jsp page with two combo boxes ( single select ).
    Here's a snippet from the jsp page containing the code for the two combo boxes:
    <form name="frmCountry" id="frmCountry" method="POST">
         <select name="selCountry" id="selCountry">
              <jsp:include page="/country" />
         </select>
    </form>
    <form name="frmCity" id="frmCity" method="POST">
         <select name="selCity" id="selCity">
              <jsp:include page="/city" />
         </select>
    </form>
    "country" and "city" are both mapped to servlets in the web.xml file
    The country servlet successfully connects to the database and retrieves all countries
    and populates the country combo box.
    However, the populating of the city combo box depends on what country
    is selected in the country combo box;
    Here is a snippet of my code from the City servlet:
    ResultSet rs;
    rs = statement.executeQuery("SELECT City.countryID, City.id, City.name " +
                   "FROM City " +
                   "WHERE City.countryID = ( Country id ) " +
                   "ORDER BY City.name");
    Where ( Country id ) has to be somehow retrieved from the Country combo box
    on the jsp page. Country id is actually the "value" property of each <option> in the
    Country combo box. i.e.:
    <option value="5">Portugal</option>
    If it's not possible to retrieve the value property from the option,
    I could always just use the Country name
    So to reiterate, I need the City servlet to be called into action
    any time a different country is selected in the country combo box.
    I'm a newbie to jsp & servlets, so any suggestions much appreciated.
    Edited by: Irish_Fred on Jan 20, 2010 4:29 AM

    Cheers, I came up with a solution using Ajax, where I didn't have to change
    anything in my servlets and only had to make minor changes to my jsp page.
    I didn't want to use any javascript in my web app, but I guess Ajax
    has addressed the issue of cross platform independence.

  • How to catch ClassCastException from JSP page?

    I get a ClassCastException within my JSP page and I know where my bug is. However, this classcastexception message is displayed in the browser and I want to catch this exception to also log it into my log file. But I can't find the place where to catch it: in my servlet's doPost() method I can't catch it - i tried it by enclosing the method body with try/catch but it isn't catched. I wonder if I can catch it at all or if this error is handled internally in the servlet engine?

    It should only be displayed in the browser if you're not catching the exception in the jsp itself. If the exception is happening in the jsp, then there's no point in trying to catch it in the servlet.
    What happens if you put a try-catch just around the actual code in the jsp? You could put it around the entire jsp, but that's not necessary.
    One problem I've encountered in catching exceptions is if there are escape sequences within the try block, for example:
    try{
       //java code
    %>
       <!--html -->
    <%
    //java
    catch (Exception e)I'm not sure if that works or not, but to be safe, make sure you're not escaping from jsp within the try block.

  • Calling Classes From JSP pages

    I am importing an application specific class in a JSP page and calling it
              (Win NT). It compiles the servlet successfully but cannot appear to find the
              class during execution.
              I have tried placing the class file / jar file containing the class in
              CLASSPATH environment / weblogic JAVAPATH variable / weblogic ServletClasses
              directory .. so far without any luck.
              I would appreciate any suggestions.
              Regards,
              Pradeep
              

    Put it in WEBLOGICCLASSPATH variable. And make sure it is only in
              WEBLOGICCLASSPATH , nowhere else.
              Cheers - Wei
              John Brown <[email protected]> wrote in message
              news:39693f9e$[email protected]..
              > I am importing an application specific class in a JSP page and calling it
              > (Win NT). It compiles the servlet successfully but cannot appear to find
              the
              > class during execution.
              > I have tried placing the class file / jar file containing the class in
              > CLASSPATH environment / weblogic JAVAPATH variable / weblogic
              ServletClasses
              > directory .. so far without any luck.
              > I would appreciate any suggestions.
              >
              > Regards,
              >
              > Pradeep
              >
              >
              >
              

  • How to call webservices from ADF page

    Hi,
    I am using ADFBC.
    I want to call webservices from ADF page.please give examples of sample program on how to call a web service from the ADF pages.please give examples.
    please help me.
    Thanks,

    http://marianne-horsch-adf.blogspot.com/2011/03/how-to-create-web-service-based-adf.html
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/70-dependent-listboxes-using-ws-286107.pdf
    http://www.oracleimg.com/technetwork/developer-tools/jdev/adfcomplexwstypes-101013.html
    http://technology.amis.nl/blog/9726/quickly-creating-reploying-and-testing-a-webservice-interface-for-adf-business-components
    http://oracamp.com/passing-parameters-between-web-services-and-jsf-pages

  • Calling servlet from java page flow

    Hi,
    I need to call servelt class from the <netui:anchor ..> tag of my jpf.
    i have mapped this servlet class in the web.xml.
    please tell us how to invoke servlet from the netui:anchor tag from the jpf action
    method.
    thanks
    shashi

    I am calling a Servlet from JAVA Class as I am using IDE: Eclipse. The Problem is below
    URL url = new URL(ServletPath);
    URLConnection connet = url.openConnection();Why should the Servlet running in different Runtime print on your Eclipse Runtime. Please be more clear about the question.

  • How to update Ztable from Excel file and how to check conditions ,

    HI this uday,
    pls help me how can i update Ztable from Excel file and how to check conditions .
    regards
    uday
    Moderator message: please (re)search yourself before asking.
    Edited by: Thomas Zloch on Jul 13, 2010 12:00 PM

    Hi
    Use Fm : ALSM_EXCEL_TO_INTERNAL_TABLE.
    L_INTERN : internal table with your fields .
    make sure that the fields in the Excel should be formatted (as numeric , characher ) depending upon the data types .
    LOOP AT L_INTERN INTO WA_LINTERN .
            MOVE WA_LINTERN-COL TO L_INDEX.
            ASSIGN COMPONENT  L_INDEX OF STRUCTURE WA_INREC TO <FS> .
            IF SY-SUBRC = 0.
              MOVE WA_LINTERN-VALUE TO <FS>.
            ENDIF.
            AT END OF  ROW .                                    "#EC *
              APPEND WA_INREC TO IT_DATA.  "
              CLEAR WA_INREC.
            ENDAT.
         ENDLOOP.
    Regards
    Swapnil

  • 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>

  • 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

Maybe you are looking for

  • FTP adapter settings for Anonymous login

    Hi All, Can any one tell how to configure the oc4j-ra.xml under the FTP adapter as i am using FTP adapter which did not have any login credentials(Anonymous login) Thanks andRegards, Nagaraju .D

  • Templates show up as having broken links in site link check

    CS6 I have about 20 templates for my site, and a couple of them show up as having broken links when I do a check links site wide search? When I make changes to these particular templates now, the new links and associated pages will show up as having

  • AIP-SSM inline mode Question

    Dear all i have an ASA 5520 with ips module . i installed it since 3 weeks. For the ips module , it is installed in inline mode. Till now i didnot see any events appeared on the sensor.i configured it to scan http traffic from any source to the insid

  • Standard iPhone Headset functionality issue

    I purchased the 3G iPhone when it first came out and have been very pleased. The standard headphones that came with the phone were great because I could stop and start music and pick up phone calls all with the click of a button. Well now after 3 mon

  • Help with PHP and CSS links (&mysql results)

    Hi Hope someone can help.  I have a column in a mysql5 database that records if an advert is 'featured' or not with 'yes' or 'no' in the database fields. I'm dynamically creating a list of adverts using php5 and DWCS3 where each ad comprises several