Calling servlet from a JSP page's form action

Brian J

I'm trying to pass a value input to a textbox in a JSP page to a servlet that will store the value as a variable. But when I click the submit button the servlet isn't found. I get an error stating the requested resource is not available

Servlet Class:

    //parse input from hello.jsp input box 
    //and assign to fibNum variable
    
    
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        
        
        
        
    }
    

}

I've looked at some questions like this: <form action="/sampleServlet" giving me exception but changing the path didn't change the outcome.

Does anyone know how to fix this problem calling of a servlet? Or is there a step I'm missing in linking up the servlet?

res

package

Also this is the structure of my project tree:

Jerome Anthony

You need to create servlet mapping in your web.xml. See here as well. So in your web.xml define;

<servlet>
  <servlet-name>hello</servlet-name>
  <servlet-class><package name>.HelloServlet</servlet-class>
</servlet>

Then create mappings (url patterns) for the servlet.

<servlet-mapping>
  <servlet-name>hello</servlet-name>
  <url-pattern>/say_hello/*</url-pattern>
</servlet-mapping>

Now in your JSP refernce the servlet like

 <form action="say_hello" method="get">            
   <b>Fibonacci Sequence Length </b>  <br>
   <input type="text" name="fibNum"size="20px" style="font-size:30pt;height:60px" >
   <input type="submit" value="submit" style="font-size:30pt;height:60px" > <br>  
   Value [1-100]<br>
 </form>  

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling servlet from a JSP page's form action

From Dev

calling Servlet from jsp <href> link is not working

From Dev

Multiple action for one servlet from different JSP

From Dev

Using servlet form on jsp page without redirecting to servlet

From Dev

Using servlet form on jsp page without redirecting to servlet

From Dev

perform a servlet doPost from jsp form file

From Dev

Java Servlet not receiving values from JSP Form

From Dev

getting data from servlet to jsp page

From Dev

How to get data from JSP page to servlet

From Dev

unable to redirect from servlet to jsp page

From Dev

How to get data from JSP page to servlet

From Dev

How to get id from jsp page to servlet?

From Dev

Parameter from JSP page not visible in servlet

From Dev

sending values from servlet in link to jsp page

From Dev

How to pass parameter from a jsp page to a servlet?

From Dev

calling servlet from php page using ajax

From Dev

Call servlet from servlet, and JSP (wo Form) within one application

From Dev

How to Include a JSP Fragment into a JSP Page while forwading from Servlet?

From Dev

calling Java method from jsp page

From Dev

Servlet not directing to JSP page

From Dev

Send form data from jsp to servlet using ajax

From Dev

How to send Form field values as session from jsp to servlet

From Dev

How to pass data from servlet to jsp code (out side the form)?

From Dev

PHP - form action calling itself, how to display everything in 1 page?

From Dev

Retrieving the URL generated by a form submission without calling the action page

From Dev

How to show success message on page.redirect from servlet to jsp

From Dev

Returning a value from servlet to jsp page using ajax

From Dev

how to get JSON response from servlet to jsp page by using ajax

From Dev

How to set the value returned from servlet to a Textbox in a JSP page

Related Related

  1. 1

    Calling servlet from a JSP page's form action

  2. 2

    calling Servlet from jsp <href> link is not working

  3. 3

    Multiple action for one servlet from different JSP

  4. 4

    Using servlet form on jsp page without redirecting to servlet

  5. 5

    Using servlet form on jsp page without redirecting to servlet

  6. 6

    perform a servlet doPost from jsp form file

  7. 7

    Java Servlet not receiving values from JSP Form

  8. 8

    getting data from servlet to jsp page

  9. 9

    How to get data from JSP page to servlet

  10. 10

    unable to redirect from servlet to jsp page

  11. 11

    How to get data from JSP page to servlet

  12. 12

    How to get id from jsp page to servlet?

  13. 13

    Parameter from JSP page not visible in servlet

  14. 14

    sending values from servlet in link to jsp page

  15. 15

    How to pass parameter from a jsp page to a servlet?

  16. 16

    calling servlet from php page using ajax

  17. 17

    Call servlet from servlet, and JSP (wo Form) within one application

  18. 18

    How to Include a JSP Fragment into a JSP Page while forwading from Servlet?

  19. 19

    calling Java method from jsp page

  20. 20

    Servlet not directing to JSP page

  21. 21

    Send form data from jsp to servlet using ajax

  22. 22

    How to send Form field values as session from jsp to servlet

  23. 23

    How to pass data from servlet to jsp code (out side the form)?

  24. 24

    PHP - form action calling itself, how to display everything in 1 page?

  25. 25

    Retrieving the URL generated by a form submission without calling the action page

  26. 26

    How to show success message on page.redirect from servlet to jsp

  27. 27

    Returning a value from servlet to jsp page using ajax

  28. 28

    how to get JSON response from servlet to jsp page by using ajax

  29. 29

    How to set the value returned from servlet to a Textbox in a JSP page

HotTag

Archive