Win a copy of Event Streams in Action this week in the Java in General forum!

sarah Marsh

Ranch Hand
+ Follow
since Mar 06, 2001
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 sarah Marsh

Thanks Peter. I didn't find any ATF mailing list on Javaranch.
Could you please give me the link?
The build date is back to 2007.

Thanks!
Thank you, Joe.

Is NIO necessary? IO in the newest JDK can handle what NIO need to be used. Am I correct?
10 years ago
Hello,

Is Java NIO a popular mechanism nowadays?
Any other mechanism better than this one?

Thanks!
10 years ago
Hello,

When, why to use CopyOnWriteArrayList?

Thanks!
Hello,

As of ConcurrentHashMap: Since
Retrieval operations (including get) generally do not block, so may overlap with update operations (including put and remove).
Why
all operations are thread-safe?

Thanks!
Hello,

what's the relationship between dashboard and portlet?

Thanks in advance.
10 years ago
Hello,

Has dreamweaver been used by lots of companies? By web designer or developer?

Thanks!
It's a typo in the form.
Thanks a lot, Jesus and everybody!
10 years ago
Thanks a lot, everyone! My email july4u2001@yahoo.com

LoginForm.java:

package cn.itcast;

import org.apache.struts.action.ActionForm;

public class LoginForm extends ActionForm {
private String username = null;
private String password = null;
public String getUsername() {
return username;
}
public void setUsernmae(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

}
10 years ago
Thanks, James. Here's the code.

struts-config.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
<form-beans>
<form-bean name="loginForm"
type="cn.itcast.LoginForm"/>
</form-beans>

<action-mappings>

<action path="/login"
type="cn.itcast.LoginAction"
name="loginForm">
<forward name="loginSuccess" path="/LoginSuccess.jsp"/>
<forward name="loginFailure" path="/LoginFailure.jsp"/>
</action>

</action-mappings>
</struts-config>


Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

</web-app>

Login.jsp:
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSF 'Login.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<form action="<%=path%>/login.do" method="post">
username:<input type="text" name="username"><br>
password:<input type="text" name="password"><br>
<input type="submit" value="login">
</form>
</body>
</html>

LoginAction.java:
package cn.itcast;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LoginAction extends Action {

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

LoginForm loginForm = (LoginForm)form;
if (loginForm.getUsername().equalsIgnoreCase("itcast")){

return mapping.findForward("loginSuccess");
}else{
return mapping.findForward("loginFailure");
}

}

}

Exception at if (loginForm.getUsername().equalsIgnoreCase("itcast"))
10 years ago
Hi, I'm new to Struts.
I created a simple form, it use the text input to send the form data to the server. But in the Action class when I try to get the value from the ActionForm, it has null value(so it throws null pointer exception)?
Where should I check the code?

Thanks!
10 years ago
Hi,

I'm new to Hibernate. What's difference between Session.get and Session.load?

Thanks!