About Graphic Design, PrePress, Fine Art, Programming, Application developing, Java. Something from my life.
Showing posts with label web. Show all posts
Showing posts with label web. Show all posts
Saturday, 23 March 2013
Thursday, 21 March 2013
Servlet: HTML filtering

This is my text book at the moment.
Here is some code:
The main problem is html-tags.. If you try to print out "a<b" (a less than b) - you will not see any text after < symbol. But the method filter() can replace "<" symbol with
"<" (predefined letters combination):
/** <b - as a html tag:
if (a<b) {
doThis();
} else {
doThat();
}
*/
public static String filter(String input) {
StringBuilder filtered = new StringBuilder(input.length());
char c;
for(int i=0; i<input.length(); i++) {
c = input.charAt(i);
if (c == '<') {
filtered.append("<");
} else if (c == '>') {
filtered.append(">");
} else if (c == '"') {
filtered.append(""");
} else if (c == '&') {
filtered.append("&");
} else {
filtered.append(c);
}
}
return(filtered.toString());
}
Thursday, 7 March 2013
Servlet. Reading All Request Parameters
Using request.getParameterNames() to get all parameter names.
Using request.getParameterValues(paramName) to get all (multiple) parameter values.
Enumeration paramNames = request.getParameterNames(); //All parameters
while(paramNames.hasMoreElements()) {
String paramName = (String)paramNames.nextElement();
String[] paramValues = request.getParameterValues(paramName); //All values
....
}
If the paramValues array has only one entry and contains only one empty string, then the parameter had no values. If the array has more than one entry, then the parameter had multiple values.
Using request.getParameterValues(paramName) to get all (multiple) parameter values.
Enumeration paramNames = request.getParameterNames(); //All parameters
while(paramNames.hasMoreElements()) {
String paramName = (String)paramNames.nextElement();
String[] paramValues = request.getParameterValues(paramName); //All values
....
}
If the paramValues array has only one entry and contains only one empty string, then the parameter had no values. If the array has more than one entry, then the parameter had multiple values.



An empty String is returned if the parameter exists but has no value, and null is returned if there was no such parameter which name you asked.
Wednesday, 6 March 2013
Servlet. Race condition.
Somewhere in html:
form action="SynchTest" method="POST" name="form1"
input name="SubmitBtn" type="submit" value="SUBMIT"
_______________
public class SynchTest extends HttpServlet {
Asynch a = new Asynch();
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
String title = "SynchTest";
int y = 40;
if(a.getValue() > y) {
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
out.print(ex.toString());
}
a.subtract(y);
}
String value = "Value is: "
+ String.valueOf(a.getValue());
String threadInfo = Thread.currentThread().getName();
value = value +"\n" + "Thread name is: " + threadInfo;
out.println(MyHTML_util.getHTML(title,value));
} finally {
out.close();
}
}
_____________________
Friday, 15 February 2013
PlayN (from Java + GWT) to HTML5
Cross platform game library for N≥5 platforms
Game examples:http://chrome.angrybirds.com/
http://xna-platformer.appspot.com/Platformer.html
Links:
http://code.google.com/p/playn/
http://playn-2011.appspot.com/slides/index.html
http://proppy-playn101.appspot.com
http://www.gamefromscratch.com/post/2011/10/13/Getting-started-with-PlayN.aspx
https://groups.google.com/forum/?fromgroups#!forum/playn
in Russian:
http://habrahabr.ru/post/129735/
Tuesday, 22 January 2013
Icons for web

And I had to create 2-3 absolutely new design a day. I love being busy. The more tasks - the better.
When i had a little bit more spare time i created assets for company's website.
Before it looked like this. I have began from icons. First icons I have created in Illustrator. They were vector icons with gradient. I wanted to select colour for them later. I saved each icon separately as a png-file with transparency.

Our director who was responsible for updating of corporate website asked me to separate and to rename all files for each kind of our production separately. They asked me to make different size of icons for different sizes of our production (A3, A4, A5, A6, A7 - icons should be smaller depending of paper size). It was more than 250 icons.
Subscribe to:
Posts (Atom)