You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Servlets & <strong>Server</strong>s<br />
I am experimenting a <strong>Java</strong> server application. This program has worked well<br />
It did start on the Red Hat Linux 6.0 server, but it does not open the socket, in other<br />
words, it cannot communicate with the client applet on the Linux. On this Linux<br />
server I have installed every components and all of them were running at the<br />
experiment time. Why does this server application communicate with the client<br />
applet only on the Linux? Does anyone give me a suggestion?<br />
Answer: Take a look at your port number. If it is under 1024, it is a protected port<br />
number and non-privileged users cannot touch it on Linux or any other<br />
Unix-system.<br />
Where Can I find a server to try my servlets?<br />
I am creating a client/server application. I don't run my own server<br />
and my ISP won't allow me to install and run applications from their<br />
server.<br />
Does anyone know of anywhere (preferably FREE) that will allow<br />
me to use server side <strong>Java</strong>? Any help is GREATLY appreciated.<br />
Answer: http://www.mycgiserver.com/<br />
Hi, I am using servlets. I need to store an object NOT a string in a cookie. Is that<br />
possible? The helpfile says BASE64 encoding is suggested for use with binary<br />
values. How can I do that???<br />
Answer: You could serialize the object into a ByteArrayOutputStream and then<br />
Base64 encode the resulting byte []. Keep in mind the size limitations of a cookie and<br />
the overhead of transporting it back and forth between the browser and the server.<br />
Limitations are:<br />
* at most 300 cookies<br />
* at most 4096 bytes per cookie (as measured by the characters that comprise<br />
the cookie non-terminal in the syntax description of the Set-Cookie2 header, and as<br />
received in the Set-Cookie2 header)<br />
* at most 20 cookies per unique host or domain name<br />
For more details please refer to RFC 2965.<br />
Q: Hi, I want to send a POST request, but I can't find such functionality in the<br />
servlet API, how can I do this? Must I implement this with a socket connection to port<br />
80?<br />
Answer: A servlet can do anything a standalone <strong>Java</strong> application can do. It doesn't<br />
need anything beyond what the java.net package already provides. You can use an<br />
httpURLConnection to POST to a server program like a servlet or CGI script:<br />
// Create a string with the parms you want to post and convert it to a byte array. You<br />
may need to<br />
// pass the values through java.net.URLEncoder.encodeURL()<br />
// if they have embedded blanks or special characters<br />
String parms = "a=10" + "&b=20" + "&c=30";<br />
byte[] bytes = parms.getBytes();<br />
// Create a URL pointing to the servlet or CGI script and open an HttpURLConnection<br />
file:///F|/350_t/350_tips/servlets_servers.htm (3 of 8) [2002-02-27 21:19:05]