Fórumok
How can i show this class to the portlet? / help for the errors
jb lo, módosítva 9 év-val korábban
How can i show this class to the portlet? / help for the errors
New Member Bejegyzések: 3 Csatlakozás dátuma: 2015.02.05. Legújabb bejegyzésekpackage com.test;
import com.liferay.util.bridges.mvc.MVCPortlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Portlet implementation class NewPortlet
*/
public class NewPortlet extends MVCPortlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
java.io.IOException {
res.setContentType("text/html");
java.io.PrintWriter out = res.getWriter();
out.println("");
out.println("<title>User Example</title>");
out.println("");
String username = req.getRemoteUser();
if (username == null) {
out.println("Hello. You are not logged in.");
} else if ("Bob".equals(username)) {
out.println("Hello, Bob. Nice to see you again.");
} else {
out.println("Hello, " + username + ".");
}
out.println("");
out.println("");
out.close();
request.getRequestDispatcher("page.jsp").forward(req, res);
}
}
why request in red color? what's wrong?
request.getRequestDispatcher("page.jsp").forward(req, res);
David H Nebinger, módosítva 9 év-val korábban
RE: How can i show this class to the portlet? / help for the errors
Liferay Legend Bejegyzések: 14914 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
Dude, the 1990's called and they want their java servlet code back...
Seriously we don't do crap like that anymore. There are so many newer and higher-level frameworks that we can be more productive developers without having to stoop to code like this.
Your code below fails because you're trying to hammer a servlet implementation into a round portlet hole.
Instead of coding for the servlet spec, you should be coding against the JSR-186 standard by implementing the processAction() and render() methods. And since you're extending MVCPortlet, you don't even have to play at that low level.
Seriously we don't do crap like that anymore. There are so many newer and higher-level frameworks that we can be more productive developers without having to stoop to code like this.
Your code below fails because you're trying to hammer a servlet implementation into a round portlet hole.
Instead of coding for the servlet spec, you should be coding against the JSR-186 standard by implementing the processAction() and render() methods. And since you're extending MVCPortlet, you don't even have to play at that low level.
Dave Weitzel, módosítva 9 év-val korábban
RE: How can i show this class to the portlet? / help for the errors
Regular Member Bejegyzések: 208 Csatlakozás dátuma: 2009.11.18. Legújabb bejegyzések
Reinforcing David's response, you are so lost here.
Why is "request" in red color? because it hasn't been declared, you have "req" but it still won't work
RTFM:
https://www.liferay.com/documentation/liferay-portal/6.2/development
Section 3 developing portlets
Why is "request" in red color? because it hasn't been declared, you have "req" but it still won't work
RTFM:
https://www.liferay.com/documentation/liferay-portal/6.2/development
Section 3 developing portlets