• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jstl in welcome.jsp

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys

this peice of code works in my jsp, but i was just curious if i can remove all scriplets and use jstl to make it work. any ideas will be appreciated.



=============welcome.jsp==========================
<%
final String SERVERS = com.aoc.store.utils.PropertiesProxy.getInstance().getProperty("SERVERNAMES");

//this will check if SERVERS is specified in the properties file and will return true or false

boolean clientOrAdmin = com.aoc.utils.Utils.isExternalTam(request,SERVERS);


if(clientOrAdmin == true)
{
%>

<c:redirect url="client.jsp"/>
<%} %>

<%
if(clientOrAdmin == false)
{
%>
<c:redirect url="admin.jsp"/>
<%} %>



basically this above page is the first page i am getting from <welcome-file-list> (in web.xml)


<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>

so the problem is i cannot really go to an action class from <welcome-file-list> and thus have to use scriplet in jsp.
can i avoid the scriplets in above code and use jstl instead, is that possible?

any ideas will be appreciated
thanks
J
[ May 17, 2007: Message edited by: jay roy ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

so the problem is i cannot really go to an action class from <welcome-file-list> and thus have to use scriplet in jsp.



Not correct. As of Servlet 2.4 a servlet can serve as a "welcome file".

Even if not, your welcome.jsp can easily forward to a page controller for your first page. So there is never a need (under Servlets 2.4 and JSP 2.0) to have to use scriplets with a properly structured web app.

With regards to the original question, the EL cannot make general method calls, so you'd need to factor any such calls into EL-accessilbe elements, or factor them out to the page controller.
 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>>>so you'd need to factor any such calls into EL-accessilbe elements, or factor them out to the page controller.

thanks for the reply.
I am not really sure what the above line means. how could i factor my code into EL-accessilbe elements? the problem is i have my code in welcome.jsp page from <welcome-file-list>, so i dont have much room to set or get values from the session and access them using jstl in my jsp.

thanks
J
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you need the session?

My point is that you are claiming that you need to put scriplet code in your welcome.jsp -- while I am saying that you do not.

If you have some setup code to run in a servlet that is serving as a page controller, you either set that servlet as the "welcome page" or forward from welcome.jsp to that servlet (which would then forward to the real first page after it has done its job).
 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i see what you are saying. thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic