Unable to obtain text box value (html) in jsp - html

<form name="myForm" action="MyServlet" method="POST">
Please enter your search query here:<br>
<input type="search" name="searchText" id="searchText" size="100" autocomplete="on" />
<input type="submit" name="search" value="Search" />
<textarea cols="30" rows="10">Result will be displayed here</textarea>
Click here if result not displayed for your search query.
</form>
In my servlet
arg = request.getParameter("searchText");
out.println(arg);
But I am getting the output as null.

It should be
<input type="text" name="searchText" .../>

The search type is used for search fields (a search field behaves like a regular text field).
please refer this link http://www.jguru.com/faq/view.jsp?EID=1297854 better you can change the name of the id and try or remove it and try

Related

tbm image search filter in image search query

I am trying to mirror the google image search.
so far I know that q is the name for the actual google search (or query).
On the address it will look: www.google.com/search?q=parrot
but on the google image search also appears /search?q=parrot&tbm=ish
I looked and found out that tbm stands for "to be match" and is a filter and I guess is the filter to match the images... but I don't have a clue how to put inside my html code.
So far I have done this:
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar"
<input type="submit" value="Search" class="submit">
</form>
How do I add the tbm filter? Thanks!
You can add a hidden input field and set the value of it.
example
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar">
<input type="hidden" name="tbm" value="ish">
<input type="submit" value="Search" class="submit">
</form>

How do I create a link to google image search via HTML form?

Trying to make Google Image Search Clone using HTML form where after entering text in the search field it will take you directly to Google Image search results page.
Here is the code that I am using:
<body>
<form action="https://google.com/search">
<input type="text" name="q">
<input type="submit" value="Google Search">
</form>
</body>
It will take to normal google search, how do I change it to google image search result page?
You have to change the action, as such:
<form method="get" action="http://images.google.com/images">
<input type="text" name="q" />
<input type="submit" value="Google Search" />
</form>
Google image search link is of the following format
https://www.google.com/search?q=```query```&tbm=isch
Each of the parameters, q and tbm, requires an input tag but tbm does not require any user input.
'GET_parameter_name=value' for every input tag before submit button is appended by '&'.
<form action="https://www.google.com/search">
<input type="text" name="q" id="box">
<input type="hidden" name="tbm" value="isch">
<input type="submit" value="Image Search" >
</form>
Source:
https://stenevang.wordpress.com/2013/02/22/google-advanced-power-search-url-request-parameters/
https://www.xul.fr/javascript/parameters.php

Redirect to selected site with variable which i got

<form action="/subsite/" method="GET">
<input type="text" name="" placeholder="Your Nick">
<input class="button" type="submit" />
</form>
I want to redirect I mean it should looks like
www/subsite/text
What should I use ? POST ?
The method="get" means that the parameters (and values) will be sent in the query string (the stuff after the question mark in the URL). eg.
/subsite?input_field_name=input_field_value
In your case, the input field doesn't have a name, which will cause problems. You probably want something like this:
<input type="text" name="nickname" placeholder="Your Nick">
So if you submit this form:
<form action="/subsite" method="get">
<input type="text" name="nickname" placeholder="Your Nick">
</form>
Then after submitting, the browser will go to:
/subsite?nickname=value_of_nickname_variable
If you use a method="post", then the form data (variables) will be sent along in the request body, not the query string. There are other differences between get/post, but that's one of them :)
If you just want to do a simple redirect when clicking the button, you could use javascript instead, eg.: window.location.href='/my_url_path_here'

form action parameter not working

Test
<br><br>
<form action="index.php?page=test">
<input type="text" placeholder="enter text"> </input>
<button type="submit">Send</button>
</form>
Why is the link working correctly while the form gets me the url http://example.com/index.php? in the adress bar of the browser?
Every parameter i define in the action attribute is getting cut off
you have to use this code.
Test
<br><br>
<form action="index.php" method="get">
<input type="text" placeholder="enter text"> </input>
<input type="hidden" name="page" value="test">
<button type="submit">Send</button>
</form>
You are submitting a GET form. The data in the form will be expressed as a query string and replace the one in the URL in the action.
Move the data from the query string into hidden inputs inside the form.

pass form input value to action

I have a page (module-access.php).
On the page I have a form with one text input field. I'd like to set whatever is typed in this field to be part of the form's action.
<form action="module-access.php?company=THE-USERS-INPUT" method="post" name="company" id="company">
Company Name: <input type="text" name="textfield" id="textfield">
<INPUT TYPE="submit" name="submit" VALUE="Go"></FORM>
Thanks
Just change the input name from textfield to company and the action type to GET
<form id="myform" action="module-access.php" method="GET">
Company Name: <input type="text" name="company" id="company">
<input type="submit" name="submit" value="Go">
</form>
Why? Does it matter whether it's passed in the POST or GET? You can always just use REQUEST.
If it does matter then you'll need to use JavaScript to modify the action before you POST the form. Not very hard to do.