I have created a Servlet using GENERIC SERVLET which is working fine on port 8080
But now i have CREATED another html web form file to accept the input parameters from users,
and then i created a Register Servlet(for that to accept the parameters from html page) using get parameter() method, and so that this file can accept the web form data, but when i made my request through html form data, it should accept the parameters and show the results, but instead ,
it says
"404 Not Found" Intellij Idea..
I'm using Tomcat as a webserver
PLEASE HELP ME, Iam including some screenshots and program code..
Program code for HTML :-
MY HTML CODE HERE
MY DIRECTORY IN INTELIJ
MY SERVLET CODE HERE
HTML PAGE TO ACCEPT USER FORM DATA
404 NOT FOUND ERROR
MAY BE I don't know how to manage ports ?..
Your post url is wrong. It should be /yoyo/web/Userinfoservlet instead of just /Userinfoservlet
done !, i just changed the url to localhost:8080/Register and it works !
actually the file Register servlet was listening to port 8080 and the html file was forcing to go to the invalid url –
Related
I do not have much experience with JSP/Servlets and I have searched for an answer regarding my problem but have not found an answer to my question.
Lets say I have a file on the back-end, called test.txt, and i want my servlet to stream the file contents to a jsp page dynamically. By dynamically i mean that if the file is being updated, text is being appended to the end of file, then i want the client looking at the resulting html/jsp file to see the changes live.
For example, the client would be able to see the changes in a textbox element in the html document.
Is this possible with JSP/Servlets or not? If so, how would i go about it?
Thanks for your time.
Already tried searching for related questions, searching for stream inquires
and haven't found any answer that would answer my question.
I think that you should probably load the file:
See an example: How should I load files into my Java application?
and reload the page using javascript
See: How to reload a page using JavaScript
I am sure you are not professional in web development , so lets fix it.
When a client (Mobile App , Browser , ... ) wants to send a request to a server , it will create a TCP/IP (we have more protocols like UDP but web applications work on top of TCP/IP protocol) connection. All data between client and server will transfer by this connection. It's your only way to send and receive data from server or client.
When you create a JSP file (and it will compile to Class file when deploy on server application [ for better understand search JASPER JSP ENGINE ] ) to response to requests i will produce a response like this for browser :
some Http-Headers
Content-Type : text/html
some other Http-Headers
{JSP as a html text}
so browser will parse the response , render it and show it to your client user.
It means this jsp page will sent as a static html page.
For update it you have 2 ways :
1- The wrong way : Keep-Alive connection between client and server and each time you want to update client , send whole response to it again ! So all data come and html will render again and ... . So its bad way and not safe and many things else.
2- The correct way : Create a new async connection between client and server using JavaScript and just request for watch data change in file and show it to user in real time , without render whole html page. If this connection use Http protocol (http protocol just is a text protocol not a network protocol like TCP/IP) add Connection : Keep-Alive in your request header to server keep it alive.
Note : if you want understand better , search for socket in java and learn how it works.
In my organization, all http apps undergo a security check. There are a few headers I need to add to each response via the servlet, that's easy.
But, I have a new servlet, which returns html code as a response. part of the html is:
<script type=\"text/javascript\" src= \""+_pathToScript +"myScript.js\"/>
now, the browser gets this response and then generates another GET request for the file. this request is not passing via my servlet and thus I can't add the needed headers to this response.
I tried to change the src value to something like /servlet/MyServlet?GetJS, but the browser doesn't seem to understand that and it doesn't trigger the download.
Any suggestions?
Im running on IBM WebSphere.
Thanks a lot!
I build java web application,and I try to login with cookies... So I insert user and password values, user is gerardo password 12345.. When I insert it, JSP respond my request but I get an issue...anyone can help me? I upload code here:
https://mega.nz/#F!s0V2WaZb!Q5zoZFm11VP2IJ_lc6Wolw
Note**: Im using NETBEANS IDE and GLASSFISH server
Give full path of index.html like http://domain_name/direcorry/index.html as index.html may not be present in same location of jsp file.
Here is my problem :
I have to perform post from java code to some page , get the data and parse it.
The problem is that only my country ip can post to this page. Requests from another ip's are rejected.
I want to find workaround.
I have added my html page on server in my country (this server accessible from all ips) . Now I am sending a get request (in open to all server) to this page from Java code.
What I want to do is to redirect my html page to post to the original page.
I tried to use redirection , but it doesn't work - from Java code I get my html page and not redirected one.
Is there any solution or my problem ?
Thanks
I tried to use redirection , but it doesn't work - from Java code I
get my html page and not redirected one.
Yes it wont work because redirection works on client side. You perform a request to your HTML page which sends back a redirect header and your Java implementation doesnt know what to do with it. Even if it did, it had to make a new request to redirected page, which means that the request to the redirected page would still be from a denied IP.
Another option is that your redirection HTML uses JavaScript window.location.assign or something like that. The point remains the same, beacause this also is a client side solution.
You have to use some kind of server side language on the host where you placed your HTML and in that server side script you have to perform a (post or get as you wish) request to only-your-country URL. This way this only-your-country URL will see that the request came from the host where the script was, not the client itself.
For example if you can use java as your server side language on the place where currently your redirection html is, then you can check out this thread: How to send simple http post request with post parameters in java
You need a reverse proxy installed on a server located in your country. If you make a request to this reverse proxy, it will make a request to the only-your-country server and when it gets a response it will forward it to you.
So the only-your-country server will receive the same request as you make to the reverse proxy, but with a source IP address changed to the IP of the reverse proxy server.
I have written a RIA using flex for the front-end and Java servlet for the back end which actually makes calls to a web-service to do some processing.
The welcome page is a html page which is served from the web-logic 8.1 server that the app is hosted on. The welcome page loads and the flash content loads. Even a 'xml' file containing some configuration properties gets loaded from the server (through URL Request).
Now when I click a button on the page, it would authenticate the user, by sending the data to the servlet.
Here's the problem... The servlet doesn't get invoked and the URL Request (for the servlet with appropriate parameters) returns a 500: Internal Server Error page.
The same code is working perfectly when I deploy it on my local machine using tomcat as a server. And I have also checked umpteen times if the host URL is correct when being deployed on the web-logic server. Even checked the URL when the request is being made, in firefox, using firebug, and all seems to be fine, except that the response is '500: Internal Server Error'.
Please help. Thanks in Advance.
OK, the welcome page loads, and an XML file loads from the webserver, but the servlet can't be invoked.
Is the servlet initialising correctly, and waiting to be called?
Does anything need to be changed in the web.xml file that hasn't been?
Without any more information, it sounds like a misconfigured servlet and/or app server. Check your logs to see if there's any more information there.