Mark Chen

Greenhorn
+ Follow
since Sep 03, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mark Chen

Michael, Mike:
Thanks for your suggestion and information. I would try agian and see what I could get.
Mark
22 years ago
Hi everyone,
I have a problem with HTTPS and HTTP in my servlet & JSP development.
In my project I have one servlet which takes all user' request and then transfers to different JSP according the user'request.
When users first access this web they will get the login page. After typing the necessary data users submit this login request. This request will be sent to the server via HTTPS. I did this by forcing <FORM ACTION="https://localhost:8443/...> in my login page.
When the servlet receives this request, it will process it(verify the user name & password) and then transfer the request to some JSPs. The basic logic looks like:
doPost(request, response) {
// get parameters from request
// call other server for verification
If successful
dispatcher = request.getRequestDispatcher("/jsp/success.jsp");
Else
dispatcher = request.getRequestDispatcher("/jsp/fail.jsp");
dispather.forward(request, response);
}
What I expect here is the request of submitting login is via HTTPS but after the verification everything should go back to HTTP(No SSL any more).
But I found after I submit the login request via HTTPS everything becomes HTTPS. The problem I have is how I can go back to HTTP after the login data is received vai HTTPS.
My servlet container is TOMCAT 4.0.
I apprecaite if any one could give me some help.
Thanks,
Mark
22 years ago
Thanks Bill,
I've checked that the sessions I get via request.getSession(true) are the same. I can access the JavaBean stored in session. And this JavaBean brings the data to JSP and can't bring the new data in JSP back. It seems <jsp:useBean ...> and <jsp:setProperty ...> don't do their job.
Mark
22 years ago
Hi,
I got a problem with sharing one JavaBean between Servelt and JSP. I instaniated a JavaBean called UserBean in my Servelt clas called UserController and stored it in the session object and then forwarded it to a JSP called login.jsp. In login.jsp I can access this UserBean instance(get the value which is set in Servlet). There's no problem with that. What I try to do is using this UserBean intance to bring some information the user types in back to the UserController servlet. Here the problem comes out. I find I can't get the right value which the user inputs in login.jsp. Instead I still get the value I set in UserController servelt before forwarding to login.jsp. I don't know what causes the problem and how to fix it. It would be much appreciated if someone could gives some hints or suggestions.
The servelt/JSP engin is TOMCAT 3.2.3
My code snippets:
UserBean.java
public class UserBean {
private String customerID;
public UserBean() {
}
public String getCustomerID() {
return customerID;
}
public void setCustomerID(String cID) {
customerID = cID;
}
}
UserController.java
public class UserController extends HttpServlet {
......
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession(true);
UserBean user = null;
user = (UserBean)session.getAttribute("User");
if ( user == null ) {
user = new UserBean();
user.setCustomerID("13456");
session.setAttribute(UserBean.USER, user);
}
RequestDispatcher rd = null;
String page = request.getParameter("Page");
if (page == null ) {
rd = getServletConfig().
getServletContext ().
getRequestDispatcher("/jsp/login.jsp");
} else if (nextPage.equals("LOGIN" ) ){
UserBean f = (UserBean)session.getAttribute("User");
if ( f != null ){
System.out.println("ID="+f.getCustomerID()); //???
}
}
if ( rd != null ){
rd.forward(request, response);
}
}
}
login.jsp
<%@ page import="superVISor.*" session="true" %>
<jsp:useBean id="User" class="superVISor.UserBean" scope="session" />
<jsp:setProperty name="User" property="customerID" param="customerID"/>
......
<FORM ACTION="/superVISOR/UserController" METHOD="post">
......
<INPUT TYPE="text" NAME="customerID" VALUE='<%=User.getCustomerID()%>' SIZE=30 MAXLENGTH=35></TD>
<INPUT TYPE="submit" VALUE="Submit">
<INPUT TYPE="reset" VALUE="Reset">
<INPUT TYPE="hidden" NAME= "Page" VALUE="LOGIN">
22 years ago