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 6472773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:23:10+00:00 2026-05-25T06:23:10+00:00

i am really new to java, and jsp. so it is understandable that i

  • 0

i am really new to java, and jsp. so it is understandable that i cant really understand the scope of parameters
here is my code:

<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%!
     String sRony= new String();
     void func() {
        sRony += " - add in func() - ";
    }
%>
<%
     if (request.getParameter("ron")!= null){
         sRony = request.getParameter("ron");
         func();
     }
     if (request.getParameter("sleep")!= null){
        Thread.sleep(2000);
     }

%>
<html>
<head>
</head>
<body>
  <%=sRony%><%= new java.util.Date() %>
</body>
</html>

the problem is that this code is not thread safe. if you’ll surf to

page.jsp?ron=sleep&sleep=1

and at the same time to

page.jsp?ron=no_sleep

both page will print the “no_sleep”, cause the parameter sRony is global.
if i’ll remove the ! from <%! the parameter sRony will not be recognized inside void func()
i cant figure out how can i declare a parameter that will be per request, and will have the scope inside my function.
not sure if my platform is important information, i am working on redhat 5.5 64 bit, glassfish server 3.
any help ?

  • 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-25T06:23:11+00:00Added an answer on May 25, 2026 at 6:23 am

    use pagescope and use JSTL instead javacode

    <c:set var="name1" value="value1" scope="page" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really new to Java and I read that synchronized is very expensive
First I want to say that I'm really new to neural networks and I
I am new to JSP and I am trying to write the below code:
I am really fresh at Java. I'have created new Java Project. Created package Main
I am using Silverlight4 with java webervices in jsp page. I want to save
I'm still fairly new to PHP and so I'm attempting to understand scope concepts
I am new to JSP and Java Servlet. I am quite confusing about Session
In a Java update FAQ it mentions a new thing called Java Kernel: http://java.sun.com/javase/6/6u10faq.jsp#JKernel
I'm really new to Java and I have to create an applet for signing
I'm creating a new Java project for a concept/construct that's usually referred to with

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.