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 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

Related Questions

Its generally related to a question in magento ..but i think using core php
The Wikipedia article on Continuation says: In any language which supports closures , it
Thread is in continuation of sending-data-back-to-controller-spring-mvc I am working on a product detail page
This is a continuation of my last question. (thanks for the answer) Im using
I decide to learn more about vim and its syntax highlighting. Using examples for
this is a continuation of question Catching an exception while using a Python 'with'
Suppose I need to track my clicks using google analytics scripts. I know that
Its tedious to always check your bank account website for new monthly statements. (They
Its more of a best practices sort of question. Here it goes... I have
Its too much code to paste here so, I have created demo please have

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.