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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:09:15+00:00 2026-05-12T09:09:15+00:00

Ok its a continuation of my crap attempts of using client side scripts along

  • 0

Ok its a continuation of my crap attempts of using client side scripts along with server side elements.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<form name="test" action="test.jsp" method="post" enctype="multipart/form-data">
<select name="harish" onchange=callme();>
<option value="1">1</option>
<option value="2">2</option>
</select>
<script> 
var jsvar="Hello";
function callme()
{
    alert(jsvar);
    jsvar=document.getElementById("harish").value;
    alert(jsvar);
}
</script> 
 <% 
 String s=(String)("<script>document.writeln(jsvar)</script>").toString();
 out.println(s.equals("Hello"));
 if(!(s.equals("Hello")))
 {
 String jspvar="<script>document.writeln(jsvar)</script>";
 out.println("jspvar"+jspvar);
 session.setAttribute("test",jspvar);
 }
  %>
</form>


</body>
</html>

Now what I am trying is to set the selected value as a session variable.But my bad the value from javascript is not sitting properly on the jsp/java variable and therby my condition if(!(s.equals("Hello"))) fails.Can anyone help me here…

Update:

Can the below be the solution for this question

Have a HTML page with two frames. Let the first page contain all the javascript values you wish to populate. The second page(hidden) of the frame actually does the trick. That is actually a JSP. On click of a button (on any action on the first page) in the first page, point your location to the hidden frame (2nd page), perform checks / conversions and populate the variable of the first page using cross frame JAVASCRIPT.

  • 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-12T09:09:15+00:00Added an answer on May 12, 2026 at 9:09 am

    my condition if(!(s.equals(“Hello”))) fails

    That is because this:

    String s=(String)("<script>document.writeln(jsvar)</script>").toString();
    out.println(s.equals("Hello"));
    

    …is pretty much the same as writing:

    out.println("this".equals("that"));
    

    It will always be false.

    Now what I am trying is to set the selected value as a session variable.

    To set a variable in the session, you need to POST the form to the server (ignoring AJAX techniques, etc.). As I mentioned here, using multipart/form-data requires a MIME parser – the form below uses the default enctype.

    This form will, when you select an option from the drop-down, post the form to the server. Every time the JSP is run, it uses a scriptlet <% ... %> tests to see if a “harish” parameter has been posted. If it has, it places it in the session. An expression <%= ... %> is used to display the current session value.

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <!-- header removed for clarity -->
    <body>
    <form id="test" name="test" action="test.jsp" method="post"><select
      name="harish" onchange="document.getElementById('test').submit();">
      <option value="select">select an option</option>
      <option value="1">1</option>
      <option value="2">2</option>
    </select></form>
    <%
      //see if a parameter was sent from page; "harish"==name attr on select
      String value = request.getParameter("harish");
      if (value != null) {
        //store it in session
        session.setAttribute("test", value);
      }
    %>
    <%="harish=" + session.getAttribute("test")%>
    </body>
    </html>
    

    This assumes that the above page is test.jsp – that the page posts back to itself. If not, you’ll need to move the scriptlet and the expression to test.jsp.

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

Sidebar

Ask A Question

Stats

  • Questions 252k
  • Answers 252k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Most probably not. Colored console output is done using the… May 13, 2026 at 9:39 am
  • Editorial Team
    Editorial Team added an answer Yes, you can start up the process with a pipe… May 13, 2026 at 9:39 am
  • Editorial Team
    Editorial Team added an answer you can use data_files option of distutils to install files… May 13, 2026 at 9:39 am

Related Questions

This is a continuation of this question . I'm in the process of testing
ok, its a little more complicated than the question. class A { static int
Ok, it's been a while since I've worked with classic asp so I'm a
EDIT 2009-Nov-04 OK, so it's been a little while since I first posted this

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.