Jsp code to enable and disable certain links using jsp code

Ads

 
 

Share on Google+Share on Google+

Deb
Jsp code to enable and disable certain links using jsp code
4 Answer(s)      7 years ago
Posted in : Java Beginners
Hi Everyone,

I have a doubt in JSP,I have created a web application which has priviledges of a superuser and guest..now if a superuser logs in the page gets redirected to home page where all the links under a menu should be visible and enabled whereas when a guest logs in he should be redirected to the same home page but with only a certain links only visible and enabled. now my doubt is how can i write the code to disable these links..
Can anyone help me?? its really really urgent.................!!
Please :)

Thanks in advance
Debo
Ads
View Answers

May 28, 2010 at 12:19 PM


Hi Friend,

Try the following code:

1)login.html:

<html>
<head>
</head>
<body>
<form name="form" method="post" action="http://localhost:8080/examples/jsp/mod.jsp">;
<br><br>
<table align="center"><tr><td><h2>Login Authentication</h2></td></tr></table>
<table width="300px" align="center" style="border:1px solid #000000;background-color:#efefef;">
<tr><td colspan=2></td></tr>
<tr><td colspan=2>&nbsp;</td></tr>
<tr>
<td><b>Login Name</b></td>
<td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="password" value=""></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr>
<td></td>
<td align="right"><a href="register.html">New User?</a></td>
</tr>
</table>
</table>
</form>

</body>
</html>

2)mod.jsp:
<%@page import="java.sql.*"%>
<html>
<body>
<%
String user=request.getParameter("username");
String pass=request.getParameter("password");
%>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("Select * from user where username='"+user+"' and password='"+pass+"'");
String username="";
String pwd="",type="";
while(rs.next()){
username=rs.getString("username");
pwd=rs.getString("password") ;
type=rs.getString("type") ;
}
if(user.equals(username)&&pass.equals(pwd)){
response.sendRedirect("home.jsp?user="+user+"&&type="+type);

}
else
{
response.sendRedirect("login.html");
}
}
catch(Exception e)
{}
%>
</body>
</html>

3)home.jsp:

<%
String name=request.getParameter("user");
String type=request.getParameter("type");
System.out.println(type);
%>
Welcome <%=name%>,<br><br>
<%
if(type.equals("superuser")){
%>
<a id="one" href="edit.jsp">Edit Profile</a><br>
<a id="two" href="view.jsp">View Profile</a><br>
<a id="three" href="delete.jsp">Delete Profile</a>
<%
}
else{
%>
<a id="two" href="view.jsp">View Profile</a><br>
<%
}
%>

Thanks


May 28, 2010 at 12:56 PM


Thank u so much....I will try to use this code to get some help... :)


May 28, 2010 at 12:57 PM


Thank u so much....I will try to use this code to get some help... :)


May 28, 2010 at 1:22 PM


Hi,

As per the code u posted i tried to apply it...but i have used sessions in my code.For the particular session used i have to enable/disable a link.I need a code to do that.

Thanks in advance :)

Ads









Related Tutorials/Questions & Answers:
Jsp code to enable and disable certain links using jsp code - Java Beginners
Jsp code to enable and disable certain links using jsp code  Hi... write the code to disable these links.. Can anyone help me?? its really really... have to enable/disable a link.I need a code to do that. Thanks in advance
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
Advertisements
how to enable and disable a input type in jsp - JSP-Servlet
how to enable and disable a input type in jsp  how to disable the input type and enable based on some input in the input type   Hi Friend, Try the following code: function function1(){ var n
jsp code
jsp code  hi i am Ruchi can anybody plz tell me the jsp code for searching fromwhole database. I am using Oracle10g Database.   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
JSP CODE
JSP CODE  what is the code for downloading images from database using JSP?   Please visit the following link: http://www.roseindia.net/jsp/downloadimage.shtml
jsp code
jsp code  what are the jsp code for view page in online journal
jsp code
jsp code  i want health management system project code using jsp.its urgent
JSP CODE
JSP CODE  Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me code
jsp code
jsp code  i want to jsp code which are working as,i have three drop down menu 1st menu for class second menu for subject and third menu as chapter... according to selectde menu,,,,please send me such type code,,,,plz help me
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
jsp code - JSP-Servlet
jsp code  I need code for bar charts using jsp. I searched some code but they are contain some of their own packages. Please give me asimple code... friend, Code to solve the problem : Thanks
JSP code
JSP code  I get an error when i execute the following code : <... = con.createStatement(); st.executeQuery(query); %> <jsp:forward page="address.jsp"></jsp:forward> HTTP Status 500 - type Exception report message
jsp code - JSP-Servlet
jsp code  how to count no of clicks made on a link and save it on database( using jsp)  Hi Friend, Try the following code: 1)click.jsp var numberOfClicks = 0; function hello(){ numberOfClicks
code to send sms alerts using jsp online
code to send sms alerts using jsp online  I am new to mobile aplication development. pls send me the code for sms alerts after clicking the button
jsp code
jsp code  how to display date in drop down list by jsp thus the date start from current date and for next year it has to check leap year function to february then it display 30 for some months else 31 for other months
JSP code - JSP-Servlet
me how to link these pages with each other using JSP..and how to write the code using JSP.. requriment for Newuser: 1>fname,lastname 2>Loginname...JSP code  hello,i working in project with JSP technology,i have one
jsp code - JSP-Servlet
jsp code  Can anyone help me in writing jsp/servlet code to retrieve files and display in the browser from a given directory.  Hi Friend, Try the following code: Thanks
JSP Code - JSP-Servlet
, Please visit the following links: http://www.roseindia.net/jsp/data-grid.shtml http://www.roseindia.net/jsp/paging.shtml Thanks...JSP Code  Hi, Do we have a datagrid equivalent concept in JSP
jsp code - JSP-Servlet
jsp code  sample code for change password example Old Password: new Password: confirm Password
jsp code - JSP-Servlet
jsp code  how to write a code in jsp with out using servelts finding sum and avg of 40 numbers  Hi Friend, Try the following code: Thanks  Hi Friend, Do one change in the provided code.As we
jsp code - JSP-Servlet
jsp code  Hello Everybody, can anyone help me to findout the modules as i am developing a whiteboard application using jsp? this application is my dream application. Thank you
jsp code - JSP-Servlet
jsp code  sample code to create hyperlink within hyperlink example: reservation: train: A/C department non A/c Department
jsp code - JSP-Servlet
jsp code  in a jsp a table is existed ,in table each row contain one checkbox and name and desription how to delete specific rows in a table .  Hi Friend, Try the following code: 1)form.jsp: Name
jsp code - JSP-Servlet
to generate second drop down list by using jsp? pls ?   Hi Friend...jsp code  hi my requirement is generate dynamic drop down lists... the second drop down list is displayed from mysql data base table by using select
code in jsp
code in jsp  hi.. I had started a project on college admission system in which two operators has been introduced one is admin who can view all... want a code to sort a list of students on the basis of there 12% marks and AIEEE
jsp code plz
;Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml The above links...jsp code plz  write jsp code which takes student roll number as input
jsp code - JSP-Servlet
jsp code  in my table there are 3 fields named orderid ,itemname, itemqty. i want code that fetch orderid in dropdown... on select dropdown get table of item details of that orderid... there are multiple items at one orderid
jsp code - JSP-Servlet
jsp code  i want to add below code data in mysql database using jsp... using below code we got data in text box i want to add multiple data in database... Add/Remove dynamic rows in HTML table
JSP Code - JSP-Servlet
JSP Code  Create a html reader JSP tag that read the html page from a link and will display the contents on the JSP. Do not use include directive

Ads

 
Advertisement null

Ads