Solved

Beginner Help

Posted on 2002-05-22
9
218 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
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 50 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
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 7028091
String userIDParameter request.getParameter("userID");
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
attribute vs parameter and setter vs add method 17 83
sortaSum challenge java 17 171
spring example non maven 4 82
java operators 3 110
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now