Pages

Thursday, 28 March 2013

Dispatch depending on the condition (JSP. Servlet)

The idea is easy: if condition is true - to show first JSP-page, otherwise - to show second JSP-page.
First of all i have index.jsp which makes a request to a servlet. Then that servlet uses class Client to keep all incoming information and transfers the instance of this Client class as a session's or request's attribute.

Displaying dynamically generated images in a JSP document

My small web application contains 1 java bean - helper class (Model), 2 JSP-pages (Views), 2 servlets (Controlers). First page index.jsp contains the html form to send a request with all requested information to a servlet.

Saturday, 23 March 2013

Tickets (Russian Famous Artists)

CiS. My Web Site Design.


One big poster in several stages of work.

It was a big (B1) poster for The Russian Theater of Roman Viktyuk. The play "The maids" in Latvian National Opera in Riga (Latvia). You can see some parts of that play onYouTube: http://youtu.be/iI4dYWRISxk Here I want to show the stages of that poster producing.

1.Stage. Incoming... assets. It was A4 flyer with scratches and creasing line after folding.

2. I have scanned it with 1200 ppi (pixel per inch). 
  


3. Scanned images from printed materials have one big problem: a moiré pattern (pronounced more-ay). (For more details you can read on here: http://www.scantips.com/basics06.html ). I had to remove a moiré pattern (the halftone screen) from the scanned image. I applied 1-pixels-size Gaussian Blur and decrease resolution of image several times. (I didn't use the integrated descreen filter at that time).




Thursday, 21 March 2013

Servlet: HTML filtering

I took this instance from "Core Servlets and JavaServer Pages" book by Marty Hall and Larry Brown.
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 "&lt;"  (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("&lt;");
            } else if (c == '>') {
                filtered.append("&gt;");
            } else if (c == '"') {
                filtered.append("&quot;");
            } else if (c == '&') {
                filtered.append("&amp;");
            } 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.










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, 1 March 2013

BaltHouse Ltd. Few screenshots of my works.

http://www.bhprint.lv/
This is one of the leaders of printing market in Latvia. Their customers are blue chip companies around the world.


Apple Mac. Adobe InDesign. Prepress mock-up layouts (impositions).
My own mock-ups for Candy (Italy) and MIELE (Germany).

CiS. A5 Flyers. My Design.

I think these are my best flyers design because i found the best colour solution for them. And second thing is a very good layout of elements.

Pink colour solution

Yellow & Blue, Golden gradient, Old Pin-Up style

CiS. Incoming sketch & my finished design.

Incoming sketchMy finished design
Incoming sketchMy finished design

My own hand-made B&W vector clip-art


Program: Adobe Illustrator.
I wanted to create my own vector clip-art collection. But I left this idea because it took a lot of time and i didn't see how to monetize it to get profit.