Monday, September 26, 2011

There is something money really can't buy

Please eita r english e likhte parlam na.... Mane  pujor samoy bari jabar anuvuti ta bojhanor moto capa ekhono obdi banglatei hoyni to engrezi.. hazar holeo uttarparar chele to :) .. ekhono ei "kosmo" prithibite thekeo parar addar barno gando  chitkar chechamechi r abornoniiyo anuvuti gulo samsto indriyo gulo jure acche. Nijeke kakhono khub lucky mone hoy.... "kosmo" hoyar doure je ami nei.. ..lucky noi ami?? bandhu bandhober sathe addar bhashata ekhoto o pati bangla ... hasi thatta kanna dukkho raag ekhono banglatei hioy. Pichiye porchi..jani ..but thats ok... nijer sikor er taan ta thaka je baddo jaruri. paray giye pujor samoy bhor 4 te obdi alpo salpo "jol" kheye sei sob  bandhuder sathe adda mara.... jader ke ami amar anek attiyoder der thekeo age theke chini ..mane ei jakhon bayos chilo 4 ki 5...sabe cholte sikhchi ba khelte sikhchi ba "iskool" jete sikhchi ... master card er ad ta mone pore jay mairi "Price Less" .. There is something money really can't buy :)

Thursday, September 22, 2011

A basic concept [request.getParameter vs request.getAttribite).. A lucid example

What is the difference between request.getParameter() and request.getAttribute()?

Ok, getParameter() first:

Code:
<html>
<body>
<form name="testForm" method="post" action="testJSP.jsp">
<input type="text" name="testParam" value="Hello Param">
<input type="submit">
</form>
</body>
</html>

Ok so when you click the submit button on this HTML page the form will be posted to testJSP.jsp

Code:
<!-- Code for testJSP.jsp -->
<%
String sValue = request.getParameter("testParam");
%>
<html>
<body>
<%= sValue %>
</body>
</html>

request.getParameter("testParam") will get the value from the posted form (named testForm) of the input box named testParam which is "Hello Param". It will then print it out, so you should see "Hello Param" on the screen. So request.getParameter() will retrieve a value that the client has submitted. You will get the value on the server side.

Now for request.getAttribute(), this is all done server side. YOU add the attribute to the request and YOU submit the request to another resource, the client does not know about this. So all the code handling this would typically be in servlets.

Code:
// Your servlet code
public class SomeServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP POST method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Processes requests for both HTTP GET and POST methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher rd = request.getRequestDispatcher("http://www.website.com/yourResource"); //You could give a relative URL, I'm just using absolute for a clear example.
Object object = new Object(); // You can use any type of object you like here, Strings, Custom objects, in fact any object.
request.setAttribute("ObjectName", object);
rd.forward(request, response);
}
}

Now when you call rd.forward() the request will be forwarded to the resource specified ie: in this case "http://www.website.com/yourResource"

Now in this case yourResource is a Servlet, here is the code

Code:
public class YourResourceServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP POST method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

/** Processes requests for both HTTP GET and POST methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Retrieve the object stored in the request.
Object myDispatchedObject = request.getAttribute("ObjectName");
}
}

Now you have the object that you passed from resource to resource on the server side.

Wednesday, August 3, 2011

I can't smile

Yes . Thats's true. Five days and counting; am not able to smile after my surgery . Aaah!! it hurts . Thats a real problem right !! I mean how can somebody not smile seeing something funny. For me its more difficult because my family is full of funny people who do not really look funny but are funny; of course excluding me. That does not mean that I am not funny though. I am also funny but the difference is I also look funny  with the bloated nose :Dafter the surgery. My friends call me "Naku" (The guy with a big nose) now literally I am looking like real big "Naku". Yeah enough of digression; What i was talking about? Well yes I was talking about my family members who does not look funny or do something funny conciously but still makes me smile. For example think about my Papa . Never have or had a reputation of being a super jolly fellow.Always lost in his own world and "world" means the idiot's box . Suffering from some serious OCD or obsessive-compulsive disorder  as per my diagnosis of course :).  Otherwise how can somebody watch "Trishul" in the morning "Andha Kannon" in afternoon, "Shahensha" at night in one single day and the next day starts with "Giraftaar" :). And in between if somebody wants to take the "Remote" a battle ensues as if he is watching these movies for the first time. OCD of Big B's movies!! Surely :D. Thank god my Papa does not know about this blog . He he !!

Tuesday, August 2, 2011

My first blog entry

Anything 'First' is special; so this is special , my first blog. Just had a surgery ; yeah the same old sinusitis and my same old poor nose which usually bears the brunt of it. The reason as the doctors say are the same;Ahem!  smoking . Smoking kills I know , but i dont mind it killing me :) ; but I do mind the pain of sinusities it brings on me. So never again. yes I QUIT. The first thing doctor told after I  came round is "you had your last ciggarette yesterday, unless you want to be back here in two years" :) . My next question was " What about booze?" :D .