How do i set attribute in jstl  FROM JSP -- passing to servlet

Posted on 2005-05-08
Last Modified: 2013-11-24
Dear Java experts

How do i set  an attribute in jstl  FROM JSP pages and get it back inb the servlet. I want to pass an object from JSP  and get it back in the  servlet. this is urgent ..thanks a lot ..any help is very much appreciated.
Test subbu
Question by:Testsubbu
    LVL 16

    Expert Comment

    Hi subbu,

    Why do you use JSTL?

    >>" I want to pass an object from JSP  and get it back in the  servlet"
    In your JSP, you can use scriptlet <% %> such as

    request.setAttribute("yourobject", object);

    Then in your servlet, you can have it like....request.getAttribute("yourobject");

    Please let me know if you have different situation.

    LVL 16

    Accepted Solution


    Alternatively, you can use <c:set> to do that.

    You may modify the scope either in page or request or session or etc.

    LVL 29

    Expert Comment

    As suprapto45 says you can use c:set, specifically setting a variable into the correct scope. either "requestScope" or "sessionScope". I would recommend that you avoid using scriplets in your code unless there is no other way.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now