Solved

Beginner Help

Posted on 2002-05-22
9
219 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How To Remove a Principal from HttpServletRequest 4 44
HTML5 vs JSP - REST based application development 4 1,042
spring example non maven 4 87
throw exception 21 42
One of the biggest threats in the cyber realm pertains to advanced persistent threats (APTs). This paper is a compare and contrast of Russian and Chinese APT's.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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

10 Experts available now in Live!

Get 1:1 Help Now