Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3665274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:44:30+00:00 2026-05-19T01:44:30+00:00

First of all, I need to make it clear – this is for an

  • 0

First of all, I need to make it clear – this is for an academic project. I also feel I should say that I know this is the wrong way of doing what I need to do, however, it’s the way I have to do it, so please stick to answering the question if possible rather than alternatives.

I have to display the results of an SQL query either in JSTL or through a servlet, depending on whether the browser is a phone or not. I’ve managed the JSTL part, and determining whether it’s a phone, and I can forward to a servlet fine.

The problem is, I need to be able to access the result variable from the servlet. It’s easy enough to access this from the next JSTL page, as I can set the scope to application, however I’m not sure how to go about getting access from the servlet.

I’ve tried:

request.getParameter("viewResult");

but this only returns a string, whereas I believe I need a

javax.servlet.jsp.jstl.sql.Result

object.

Does anyone know of a way to pass an object from a JSTL JSP page on to a servlet when forwarded?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:44:30+00:00Added an answer on May 19, 2026 at 1:44 am

    The HttpServletRequest#getParameter() returns HTTP request parameters which are implicitly always Strings since that’s just specified so in the HTTP specification.

    You rather want to set it as request attribute. You can do that with var attribute of sql:query.

    <sql:query dataSource="${dataSource}" var="result" scope="request">
        SELECT * FROM foo
    </sql:query>
    <jsp:include page="/servletURL" />
    

    This way it’ll be available in the servlet as follows:

    Result result = (Result) request.getAttribute("result");
    

    Needless to say that this is indeed not the best practice. Those tags are designed for quick prototyping, not for real world applications (Sun/Oracle’s own words). You should rather be obtaining the DB result in doGet() or doPost() method of the servlet (for preprocessing resp postprocessing).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all I need to say that I'm new to jQuery. When I
First of all, I want to make myself clear that I do understand that
First of all, sorry for my English. I need some help with this. Recently
All I need this for is strcpy(). I want to see whether the first
First of all I'm not sure this is even possible, however I need to
So... First, I should make my goal clear. My goal is to have an
Edit: Maybe I should make this part clear. A user is writing the template.
First of all, I know that don't reinvent the wheel there are lot of
The need is such clear that first I pauseAll schedulers and before resumeAll I
First let me explain why I am asking this question so its clear that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.