Solved

Beginner Help

Posted on 2002-05-22
9
216 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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