Accessing task variables in custom form code

I'm developing a custom form for a task. I have the JSP file containing the html code and the java code. I need to manipulate task variables with Java. The only useful guide I found is "Custom form for beginners", but it's not very clear about the entire process ( I just understood I need to manipulate the "itemXML" file). Plus, it puts together reading and updating the task variables, becoming confusing. How can I access task variables using Java?

Exchange data between tasks

I have a task with a codelet. I need to pass the result from this task to another task in the same net, using variables.
1) How can I do it? 2) In my codelet, I set my output params. How can I retrieve these params (and their value) in the workflow editor?
Sorry if I'm asking something very basic, I've not found solutions in manuals and in the forum. Thank you