Reputation: 4671
Is it possible to send a request to a java servlet from a html file that is not in the project?
That is, is this possible
<form action="http://example.com/Myapp/savedetails.do" method="post">
// other fields
</form>
from a remote html file.
Note: i am trying to send a html formatted mail, and allow the users to fill forms through email and submit it in the email itself..
Upvotes: 0
Views: 303
Reputation: 280168
You don't call a Java servlet.
A Servlet
is a class which a Servlet container uses to handle requests.
Your HTTP client, a browser, serializes a form and sends an HTTP request to whatever is specified in the form's action
attribute. The Servlet container receives this request, uses the Servlet to handle it, and sends back an HTTP response.
So your browser is simply sending a request. If you specify a URL for a server which is listening and can respond for that request, then you will get a response. The client has no knowledge that a Servlet actually handled it.
What do you think would happen if you did this
<form action="http://www.google.com" method="post">
// other fields
</form>
Can you not send a request to google because google isn't in your project? What you specify in action
is just a URL.
Upvotes: 1
Reputation:
You can do it, provided there are no restrictions to make such request. For example try this link its to make search for Black Panther
with given search engines:
Also consider the request method being used at the server end, for example the above link won't work with 'POST'
method.
Upvotes: 1