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

  • SEARCH
  • Home
  • 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 8399345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:16:44+00:00 2026-06-09T21:16:44+00:00

I need to know to resize an image (it needs to be passes as

  • 0

I need to know to resize an image (it needs to be passes as img src="blah.jpg?width=x) so my page can be displayed at different sizes, can someone help me out here? I just need x (width) as a jsp variable.

2021 update: Wow, 9 years later. If you’re looking at this (and some of you still are) — Javascript has come an AMAZINGLY long way in the past 9 years. As the comments below say, this isn’t possible in JSP, but it is possible in Javascript, and CSS3. If you’re trying to determine the width of a page to resize elements on the fly, you’re likely not respecting responsive principals that have been developed over the ages. Look into CSS Flexbox and design with that in mind.

Cheers

  • 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-06-09T21:16:45+00:00Added an answer on June 9, 2026 at 9:16 pm

    What you are asking for can’t be done in this way. Your JSP is rendered on the server, and sent to the browser as HTML. Only once the page reaches the browser, is the screen width available (using JavaScript). So getting it as a JSP variable is simply not possible.

    What you could instead, is use JavaScript to get the screen width in the previous page, and set it as a query parameter in a link, or as a form’s hidden field. When the link is clicked, or the form is submitted, you can access the request to get the screen width.

    Of course, this doesn’t work if it’s possible for the user to access the URL for that page by entering it directly in the browser.

    Alternatively, use JavaScript to load the image after the page has loaded. You’d have the screen width at this time, and could construct the URL accordingly. Essentially, you’d use the onload event of the body (or $(document).ready in JQuery), to call javascript, that sets the src attribute of your image, to the URL that you need to use.

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

Sidebar

Related Questions

I have image (500x500) but I need to resize it to 200x200 and paint
I need to know the image size when it loads from an extern URL
How can I resize an image using HTML/CSS only (i.e no server code) while
I need to resize/crop images in different resolutions for Android App. I know, that
I need to do two things to an image: resize it, then crop it.
I need to resize an image in rmagick from its current size to a
Need to know this so that i could send DTMF and that is going
Need to know which event triggered after text selection done in Apple iPad. It
I need to know how to change background of expanded list item when it
I need to know how to exclude files/folders from php generated zip. Here is

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.