| Author |
Setting page var in scriptlets function?
|
Marko Debac
Ranch Hand
Joined: Aug 21, 2006
Posts: 121
|
|
Hi, I cant make it to run we service function in JSP because I cant get request variable from the same page: I have login.jsp page: And when I run the code I get an error: So, how can I set variable in scriptlet function? Maybe with pageContext? But how? Regardes, Marko [ November 06, 2006: Message edited by: Bear Bibeault ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56191
|
|
Firstly, why are you mixing JSTL and scriplets in the same page? Messy. I'd recommend using one or the other. Secondly, using a JSP for authentication in this manner is pretty old-fashioned. I suggest you bone up on the use of servlet filters. And finally: String username = (String) request.getParameter(username); Carefully look at that line. What is it you are expecting to pass to the getParameter method? The contents of the variable username that you haven't set yet? [ November 06, 2006: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Marko Debac
Ranch Hand
Joined: Aug 21, 2006
Posts: 121
|
|
Hi Bear,
why are you mixing JSTL and scriplets in the same page? Messy. I'd recommend using one or the other.
I must do so, because I am calling web service operation, and Netbeans do generation of scriptlet code by him self.
Secondly, using a JSP for authentication in this manner is pretty old-fashioned
I am not doing authentication, this is only simplified example, so I could show my problem. And I have modify code (two e in usernamee): and I still get an exeption: org.apache.jasper.JasperException: Unable to compile class for JSP Generated servlet error: [javac] C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\MailAgregator\org\apache\jsp\noviKorisnik_jsp.java:170: cannot find symbol [javac] symbol : variable usernamee [javac] location: class org.apache.jsp.login_jsp [javac] String username = (String) request.getParameter(usernamee); [javac] regardes, Marko
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1004
|
|
JSTL and scriptlet code don't share the same variable space. ${username} is approximately equivalent to <%= pageContext.findAttribute("username") %> <c:set var="username" value="${param.username}" scope="request" /> is translated into java as request.setAttribute("username", request.getParameter("username")); The JSTL code has no interaction at all with scriptlet variables declared on the page. That is why the recommendation is to use one or the other. I would recommend you try IMO this should probably be written into a servlet in any case which does the login and then uses the request dispatcher to forward to a result page, or back to the login page if the login attempt failed. Cheers, evnafets
|
 |
 |
|
|
subject: Setting page var in scriptlets function?
|
|
|