This article has been moved here:
This article has been moved here:
In this post I will show a simple code and explain how to pass information between Jsp and Servlet. This information sharing is highly essential for many programming scenarios encountered in real time.
We will pass information to and fro between servlets and jsp using sessions and servlet context information.
I presume you know how to invoke a servlet from a jsp page by making entries in web.xml in Tomcat Container.
If you are using Eclipse, the latter will take care of the mapping, though in some cases you would have to manually make the entry in web.xml (Deployment Descriptor).
We got 4 files here:
Lets see some action!
This is the form we have in Page1JSP.jsp
Notice that we are passing the form data “tName” to a servlet named “Page2Servlet”.
Output of Page1JSP.jsp:
We obtain form data sent by Page1JSP.jsp in the service() method of the servlet:
Next, we create a session and set an attribute named “Page2SessAttr”
Page2SessAttr contains the form value received from Page1Jsp. You can also set any another value into it.
Next, we obtain the Servlet Context and set an attribute in it, so that when we pass a servlets context to a Jsp , the latter would be able to access the attribute set and “forwarded” by the servlet.
Page3Jsp will receive the entire context of the servlet, that includes even the attributes set by the latter.
We will access the values sent by Page2Servlet both by the session and through the servlet context.
In Pag3Jsp, we have just accessed that session and NOT created a new session. This you can know from the following line in the above code:
HttpSession sess = request.getSession(false);
The parameter “false” indicates that this is an already created session.
Finally, In Page4Servlet.java
We will access the session attributes set by Page3JSP.jsp
In addition, “recvStr2” contains the value of “Page2SessAttr” set in Page2Servlet session.
The final output I see in my Eclipse console is:
I hope, this piece of material was clear enough to explain you how to share values between Servlets and Jsp. There may be other methods of sharing too, but this seems fairly simple to me.
If you are not clear with my explanations in tutorial just read follow the code snippets alone.
Share this post if you like it!
மணிமேகலை பிரசுரத்தின் “கண் திருஷ்டிகளும் பரிகாரங்களும்” என்ற புத்தகத்தை சமீபத்தில் நான் படிக்க நேர்ந்தது. அதில் சில சுவாரசியமான செய்திகள் குறிப்பிடப்பட்டு இருந்தன. அவற்றை இப் பதிவின் மூலமாக உங்களுடன் பகிர்ந்துக் கொள்கிறேன். நம்புவர்கள் நம்பலாம், நம்பாதவர்கள் இதன் சுவாரசியம் கருதி தொடர்ந்து படிக்கலாம்.
உலக வரலாற்றிலும் “திரிஷ்டி” சில சுவாரசியமான இடங்களைப் பிடித்திருக்கிறது.ஹிட்லரின் ஸ்வஸ்திக்(swastik) சின்னமும் திருஷ்டியோடு சம்பந்தப்பட்டு இருந்ததாக ஜேர்மன் ஆராய்ச்சியாளர்களே கூறுகின்றனராம். வீட்டில் பல்லிகள் இருந்தால் திருஷ்டி பாதிப்பு வராது என்பது மலேசியா மக்களின் நம்பிக்கை. பிரிட்டன் மக்கள், தம் நாட்டில் குரங்குகள் அதிகம் இருந்தால் அது நாட்டிற்கும் தங்களுக்கும் தோஷம் ஏற்படாமல் இருக்கும் என்று நம்பினார்கள். ஒரு கட்டத்தில் குரங்குகளின் எண்ணிக்கை குறைய ஆரம்பித்தவுடன் மக்களிடையே பீதி பற்றிக்கொண்டது. இதை அறிந்த அன்றைய பிரிட்டன் பிரதமர் வின்ஸ்டன் சர்ச்சில்(Winston Churchill) இரவோடு இரவாக வெளிநாடுகளிலிருந்து நிறைய குரங்குகளை இறக்குமதி செய்துள்ளார்.
கண் திருஷ்டி மனிதர்களை மட்டுமல்ல, மற்ற உயிரினங்களையும், உயிரற்றவைகளையும்(நிலம்,பயிர்) பாதிக்கும்.
DR S SURESH goes on a spiritual sojourn as he re-visits some prominent and lesser-known temples in and around Thiruvanmiyur.
The festival season has set in and all the temples in the city are busy preparing for special events and rituals connected with each festival.Thiruvanmiyur,which is presently a bustling residential locality on the southern fringes of Chennai city,was,for centuries,a small village with large temples and traditional tile-roofed houses.It was one of the last villages to be included within the modern city.
Thiruvanmiyur has a long and interesting history.According to the locals,the very name Tiruvanmiyur is derived from the name of the famous saint Valmiki,the author of the epic,Ramayana.He is believed to have lived here for some years,several centuries before Christ.There is a small temple dedicated to this saint in the area.
Between 300 BC and 300 AD,Roman traders frequented Thiruvanmiyur,which was then a part of the kingdom of the Sangam Cholas.The Romans came to India to buy our spices,gemstones,textiles,ivory and sandalwood.In return,India got wine,gold,silver and lead from Rome.Since the 19th century,Roman coins have been recurrently reported from the Mahabalipuram-Thiruvanmiyur coastal stretch.Thiruvanmiyur was located between two major ports frequented by the Romans,namely Mahabalipuram or Mallai and Mylapore.In Greek literature,the former port was called Malange and the latter port,Mylarpha.
After the decline of the Sangam Cholas,Thiruvanmiyur came under the control of the Pallava dynasty (fourth to ninth centuries AD).An interesting coin minted by this dynasty was unearthed from the compound of a school in Thiruvanmiyur in August,1989,when the school authorities were digging the ground for Independence Day celebrations.The coin was made of lead.It featured the bull,the royal crest of the Pallavas,on the obverse and a vase with a tree on the reverse.On typological grounds,archaeologists have assigned this coin to the fourth century AD.After the Pallavas,Thiruvanmiyur came under the rule of the Medieval Cholas or Imperial Cholas and later,the Vijayanagar empire.Subsequently,the region was passed on to the British.
The biggest and most important temple in Thiruvanmiyur is undoubtedly the Marundisvarar Temple on the East Coast Road.This temple has two main entrances – one facing east and the other facing west.Although the temple existed during the age of the Pallavas,most of the structures in the campus belong to the time of the Cholas and the Vijayanagar empire.The temple was extensively damaged when Hyder Ali,the Sultan of Mysore,invaded the area in the eighteenth century.Unlike many other Hindu temples where the main shrine faces east,the principal shrine in the present temple faces west.The vimana or tower above this shrine is over 30 feet high.The shrine of Goddess Tripurasundari faces south and belongs to the period of the king Rajendra I Chola (1012-44 AD).To the north-east of the temple is a large tank with a pillared Niradum Mandapa (bathing pavilion ).The tank has been cleaned and restored recently.It is rather strange that this beautiful temple has not got the publicity that it richly deserves.It is rarely visited by tourists.Hundreds of people pass by this temple each day,while driving to the tourist sites of Mahabalipuram and Dakshinachitra,but none of them are aware of its unique heritage.
The writer is the Tamil Nadu State Convener,INTACH and is presently in Washington DC,studying the American system of Heritage Conservation,as a Fulbright Scholar and this article appears in Times of India Chennai Edition dated 22.10.2011
The Valmiki temple in Thiruvanmiyur, which is steeped in legend, is believed to be at least 1,300 years old.
Be it a huge edifice in the centre of the road or just a small elevation beneath a tree, temples have always had special significance in Chennai.
And the Valmiki temple, sitting bang in the middle of East Coast Road in Valmiki Nagar is no exception.
Legend has it that poet Valmiki, after writing the Ramayana, was heading south along the sea shore and rested here.
Hence, the area is called Thiruvanmiyur. Although the temple looks like a mandapam, it is believed to be at least 1,300 years old.
During the Chola reign, the Maruntheeshwarar temple was constructed. Now the Valmiki temple is officially under the supervision of Maruntheeshwarar temple. But the Valmiki temple has been under threat from the development of ECR. The government planned to demolish the temple as it is in the centre of the road.
“The temple authorities have managed to get a stay order on the demolition.Now attempts are being made to widen the road around the temple, so that it will serve as a median and not be an inconvenience,” says Kuppuswamy, an officer at the Maruntheeshwarar temple.
Every year the Brahmatosav festival takes place in March and special pooja is done every month on the full moon day.
The above piece of information appears in the Chennai edition of The Hindu, dated Jan 23,2003.