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 8979079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:45:50+00:00 2026-06-15T19:45:50+00:00

im just beginning coding with JSP. I just get confuse how to make the

  • 0

im just beginning coding with JSP. I just get confuse how to make the button in my table query visible only for admin session. here’s my code:

   <% if(session.getAttribute("user").equals("admin")){
   %><script> $(document).ready(function(){
   document.getElementById("btn_lihat").style.display="block";});</script></code></pre>


    <% //some form submit }
                           %>

and here’s my table with query…

 <table border ="1">
 <tr bgcolor="#7a9ac3">            
                <td>No</td>
                <td>Perihal</td>
                <td>Tanggal</td>
                <td>Jenis</td>
                <td>Tujuan</td>
                <td>Gambar</td>
                <td>Ket</td>
            </tr>
 <% 
 try{
    Koneksi konek = new Koneksi();
    Connection conn = konek.bukaKoneksi();
    Statement stm = conn.createStatement();
    String sql = "select * from surat";
    ResultSet res = stm.executeQuery(sql);
           while(res.next()){
               %>
               <tr>
                <td><%=res.getString(1) %></td>
                <td><%=res.getString(2) %></td>
                <td><%=res.getString(3) %></td>
                <td><%=res.getString(4) %></td>
                <td><%=res.getString(5) %></td>
                <td><a href="<%=res.getString(6) %>"><img src="<%=res.getString(6) %>" width="60" height="80"></a></td>
                <td><a href="ServletSurat?nomor=<%=res.getString(1) %>" ><div id="btn_lihat" style="display: none"><input type="submit" name="cmd" value="lihat" id="lihat"></div></a></td>
            </tr>

     <%
           }}
   catch(Exception e){
      out.print(e);
        }
   %>
 </table>
  • 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-06-15T19:45:51+00:00Added an answer on June 15, 2026 at 7:45 pm

    Its better to check whether its admin, at the time of adding button.
    Change

    <td><a href="ServletSurat?nomor=<%=res.getString(1) %>" ><div id="btn_lihat" style="display: none"><input type="submit" name="cmd" value="lihat" id="lihat"></div></a></td>
    

    to

    <td><a href="ServletSurat?nomor=<%=res.getString(1) %>" >
    <% if(session.getAttribute("user").equals("admin")){%>
    <div id="btn_lihat"><input type="submit" name="cmd" value="lihat" id="lihat"></div>
    <%}%>
    </a></td>
    

    Its not a good practice creating button inside a tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After a long time of C-style procedural coding, I am just beginning to 'get'
I am just beginning to get into desktop application development, and have chosen C#
I'm trying to make a simple Sieve of Eratosthenes script, and I'm just beginning
I'm just beginning JavaScript, and I was wondering how to make different buttons do
I am just beginning to program in Java and I noticed that String is
I am just beginning to work with Rails. I have a model, User and
I am just beginning my journey into web development and I have a very
I am just beginning to localize an ASP.NET MVC application. Most of the strings
I'm just beginning WCF and so I don't understand exactly how the abstraction works.
So I am just beginning recently developing some simple apps for the iphone. I

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.