[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Beginner Help

Posted on 2002-05-22
9
Medium Priority
?
227 Views
Last Modified: 2010-04-01
Hi-
I am trying to read the value of a hidden field on my page. However, the output value is null rather than admin. Any help would be great.
Thanks-BG

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">

<%@ page import = "com.ca.portal.util.PathUtility,
                   com.ca.portal.util.i18n.Translator,
                   com.ca.portal.resources.util.Misc,
                   com.ca.portal.base.GlobalData" %>

<%@ page errorPage="errorpage.jsp" session ="false" %>

<html>
     <head>
          <meta http-equiv="pragma" content="no-cache">
          <title>MyWebBoard Login</title>
     </head>

     <body bgcolor="#ffffff">

          <form name="frmThis" method="post" action="login.jsp">
         
               <input type="hidden" name="userID" value="admin">

               UserID=: <%out.println(request.getParameter("userID"));%>

          </form>
     </body>
</html>
0
Comment
Question by:BeerGod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 200 total points
ID: 7027480
the hidden value must be passed to this page to display it.

if you want to display it like you have it use JavaScript as such:

    <body bgcolor="#ffffff">

         <form name="frmThis" method="post" action="login.jsp">
         
              <input type="hidden" name="userID" value="admin">

              UserID=: <script>document.write(document.frmThis.userID.value);</script>
         </form>
    </body>
</html>
0
 

Author Comment

by:BeerGod
ID: 7027622
hmm. i come from an asp background. i dont uderstand why if the html is processed server side along with the jsp why cant i ouput it server side?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7027628
html is not processed on the server side.  Java code is.  it outputs html and sends it to the browser.  Any HTML code is not accessible to the Java code.  This holds for Server Side ASP too.

CJ
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 7028091
String userIDParameter request.getParameter("userID");
0
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 7028152
Oh! You can't get the results within the same page... the html form has to be submitted first. Try this:




<%@ page errorPage="errorpage.jsp" session ="false" %>

<%@ page import = "com.ca.portal.util.PathUtility,
                  com.ca.portal.util.i18n.Translator,
                  com.ca.portal.resources.util.Misc,
                  com.ca.portal.base.GlobalData" %>

<%
   String userID = null;
   String formSubmit = request.getParameter("formSubmitName"); // same as form submit element 'name' parameter
   if ((formSubmit != null) && (formSubmit.equals("formSubmitValue"))) // same as form submit element 'value' parameter
   {
      userID = request.getParameter("userID");
   }
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">

<html>
    <head>
         <meta http-equiv="pragma" content="no-cache">
         <title>MyWebBoard Login</title>
    </head>

    <body bgcolor="#ffffff">

         <form name="frmThis" method="post" action="<%= request.getRequestURI() %>">

              <input type="hidden" name="userID" value="admin">
<%
   // only print if form submitted
   if (userID != null)
   {
%>
              UserID=: <%= userID %><br>
<%
   }
%>

              <input type="submit" name="formSubmitName" value="formSubmitValue">

         </form>
    </body>
</html>
0
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 7028158
If you want the form to call "login.jsp", you have to put the form element processing in the login.jsp file, instead of whicever file this is.
This part must be in login.jsp:

<%
  String userID = null;
  String formSubmit = request.getParameter("formSubmitName"); // same as form submit element 'name'
parameter
  if ((formSubmit != null) && (formSubmit.equals("formSubmitValue"))) // same as form submit element
'value' parameter
  {
     userID = request.getParameter("userID");
  }
%>


0
 

Author Comment

by:BeerGod
ID: 7028474
you are correct. the form must first be submitted.i recall now. thank you.
0
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 7028566
DId you accept the correct answer??
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7029517
Thanx for the "A". Good Luck.

CJ
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working from home is a dream for many people who aren’t happy about getting up early, going to the office, and spending long hours at work. There are lots of benefits of remote work for employees.
What monsters are hiding in your child's room? In this article I will share with you a tech horror story that could happen to anyone, along with some tips on how you can prevent it from happening to you.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question