Posts

Showing posts with the label j2ee

One template file for all pages using Servlets and JSP

Image
One of my recent tasks was making a new skin for one of our websites. the site had a common header, left side area and right side area that are to be shared among all pages. we used to include file for "header", "left side", "right side" in each of the pages.. it wasn't that pretty i know. I wanted to think of something better where i can define the template in exactly one file and i do not have to include that file on every new page i add. something pretty much close the RubyOnRails " ' directive to import the page content inside the template. i finally managed to do it. I'll use two simple pages to illustrate the concept: mahmoud.jsp and index.jsp what we want is to have each of the two pages displayed in a layout where is one header, banners and so. which will look like the following. I was able to do this using a servlet that intercepts the request. and loads the template jsp file and pass the desired page to as a parameter to be inclu...

URL encoding special characters

i had a weird bug yesterday that consumed a bit of my time. we have that we have an email that is sent to the user of one of our sites, with a link leading him back to his session (we add some key of the user to the link for that purpose). anyway.. we use a mail template.. a jsf page... all we need to do is to read that page (html generated for that jsf page) and replace some keywork with that parameter value i had the link in the following format http://server/servlet?target={user.key} and i should replace that "{user.key}" with the actual value of the generated key. this approach have been working fine for quite a while for that feature in several of our sites. However, recently i was reported that the link was broken and leading to the error page.. as i investigated the matter i found that the link in the emails is http://server/servlet?targetKKKKKK such that (KKKKKK is the key value)... the equal for some reason was missing.. pretty odd. i checked the content of my templa...