In my JSP I have a text box which contain a address path.  I need to pass this address value to Servlet.   How to pass a textbox value to servlet?
            Asked
            
        
        
            Active
            
        
            Viewed 809 times
        
    -2
            
            
         
    
    
        Ravi
        
- 30,829
- 42
- 119
- 173
 
    
    
        Unknown user
        
- 11
- 6
- 
                    open your browser and type google.com – Ravi Dec 15 '12 at 08:09
- 
                    2Your 'java class' being what exactly? A servlet? An applet? Better questions get better answers, but this question so far is very vague. – Andrew Thompson Dec 15 '12 at 08:12
- 
                    I think you want to get text filed value using jsp tag,am I right? – Mohammod Hossain Dec 15 '12 at 08:13
- 
                    @AndrewThompson I have a servlet class.And I dont know how to get the value from my jsp page.I'm just a beginner in java – Unknown user Dec 15 '12 at 08:21
- 
                    This is covered in chapter 1 of a sane JSP/Servlet tutorial which indicates that you have not really done any research on the subject. I warmly recommend to look for one. See also our servlets tag wiki page (put your mouse on top of `[servlets]` tag until an info box shows up and then click therein the *info* link). – BalusC Dec 16 '12 at 03:18
- 
                    @BalusC I cant get the link. – Unknown user Dec 17 '12 at 06:38
- 
                    Why did you change your question, post new question otherwise, you are not going to get new answer. – Ravi Dec 28 '12 at 06:43
- 
                    Rollback to your previous post. Do you think, whatever you will ask, we will solve you problem. This site is for sharing information. So don't do this stupid things. – Ravi Dec 28 '12 at 06:47
- 
                    @var___ i'm sorry actually I cant post a new question from my profile. That's why i'd edited my previous one.And this site is not allowing the freshers to know something about programming.As a beginner I can't ask the questions upto the standards what it expecting. – Unknown user Dec 28 '12 at 11:11
- 
                    @Unknownuser I noticed, you have silently changed the question. This is not at all accepted in community. I was going through this post and found all unrelated answer, which created so much confusion. If you have some other question, you are supposed to post new question. **never update your original question completely.** – Ravi Feb 03 '18 at 17:32
3 Answers
0
            
            
        i think you need to use Request object to get that value.
 
    
    
        V.Rohan
        
- 945
- 2
- 14
- 27
- 
                    
- 
                    Google it you ll get it request.getParameter("yourTextName") And Store it into string !!!! you ll get it – V.Rohan Dec 15 '12 at 10:14
0
            
            
        my.jsp
<form name="myForm" action="myServlet" method="post">
<input type="text" name="mytext" />
<input type="submit" name="Submit" value="Submit name" />
</form>
Write the above code inside your jsp page (i.e. my.jsp).
myServlet.java
PrintWriter out = response.getWriter();
String text = request.getParameter("mytext");
 out.println(text);
Above code will be written inside your servlet page (i.e. myServlet.java). 
Note : - Change form action according to your servlet. In my case, i have written here myServlet. 
 
    
    
        Ravi
        
- 30,829
- 42
- 119
- 173
0
            
            
        <html>
  <head>
    <title>Testing JSP</title>
  </head>
  <body>
    <h1>Welcome to JSP</h1>
    <form action="myjsp.jsp" method="POST" >
            <input type="text" name="name" />
      <p> 
        <input type="submit" name="Submit" value="Submit name" />
      </p>
    </form>
  </body>
</html>
<%
    String name = request.getParameter("name");
%>
 
    
    
        Mohammod Hossain
        
- 4,134
- 2
- 26
- 37